V
V
Vladimir Korshunov2021-02-08 13:45:19
linux
Vladimir Korshunov, 2021-02-08 13:45:19

How to connect to PC on linux via ssh?

I do not understand how to connect via ssh to another PC on linux. First, I find out on my PC its ip through ip route (it stands there, as I understand it, after the word via). Next, I try to connect to this computer from a laptop by writing ssh <username>@, but I get Connection refused. Port 22 I kind of opened with sudo ufw allow 22, so I don't understand what the problem is. Just started learning linux, sorry for a possibly dumb question. And right away I would like to find out how to open the port, I know how to close it, I looked through man ufw, it says that like this: ufw deny 22. However, when I enter this command and look at the status of the ports through nmap localhost, then there state open is written (opposite port 22), but why?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
CityCat4, 2021-02-08
@GashhLab

Here is an example of this question. I have been saying for a long time - there are windows-dummies that copy-paste actions without understanding their essence and blink their eyes, not understanding why it does not work and soon, very soon, the same Linux-dummies will appear.
Well, here they are.
Bro what the team says
service ssh status

he stands there, as I understand it, after the word via

nothing like that, there is the address of some kind of gateway, usually it is default gateway. IP is looked up by the ifconfig command
# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.7.10.26  netmask 255.255.255.0  broadcast 10.7.10.255

here 10.7.10.26 is the IP address

A
Ahmed C, 2021-02-18
@Rorus

The task is not entirely clear. Is your friend's computer on the same local network as yours, or over the Internet? In both cases, an ssh server must be running on the friend's computer, which will listen on port 22 or any other. Port 22 of a friend must be open for connections from the outside, which is very problematic in the case of remote access and being behind NAT. Well, the IP of the computer, of course. If the connection is remote, then at least the external one is not dynamic. In total, a friend needs: 1. ssh server, 2. open port (you can use any, not necessarily 22). 3. IP 4. No firewall restrictions on connection to this port.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question