0

I am new to ssh and have been racking my brains for several days over connecting a home computer to an remote computer. I found out that I can't connect, as they are on different networks. I am sure that this problem has a simple solution, but after a day of futile searching for a solution to my problem, I have to resort to your help.

My remote server is located at the IP address 192.168.0.1, and my home computer is 192.168.18.118 Both are on the same port (temporarily) 1729. The only difference is the username, the home PC username is Thomas, and the remote username is Tom.

Help please solve this problem, the usual connection by typing in the username of the remote server, the IP address of the remote server and the port of the remote server end with a timeout error. Thank you very much in advance.

EDIT 14.10.2019

The problem is that I don’t know how to use all this. I don’t know how to use all this, because on the Internet I watched a half-tone video, articles and much more, but I couldn’t find a concrete explanation of how to connect two such computers via ssh. In addition, it was not possible to find even at least some example of how this is done. Assume that the global IP address of my home PC is 70.***.**.**, and the local address is 192.168.18.118. Also suppose that the global IP address of my remote PC is 75.***.**.**, and the local address is 192.168.0.1. Both included 1729 port and hostname archlinux, username of the home PC Thomas, and the remote Tom. Now the question is, how do I connect these two computers with each other, that is, how do I access from my home PC to a remote one and vice versa? I would be extremely grateful to all of you if you could help me connect my home computer to the remote, as I really need it.

Continue EDIT 14.10.2019

I tried the way you said and got the answer

ssh: connect to host 75.***.**.** port 1729: Connection timed out

For the sake of interest, I tried to connect to my home PC in this way, only with the global IP address of the home PC and with the username on the home PC, and I got this response

ssh: connect to host 70.***.**.** port 1729: Connection refused

EDIT 15.10.2019

$ ss -nltu                                                                                                                                                                                                     
Netid   State Recv-Q Send-Q  Local Address:Port  Peer Address:Port  
udp     UNCONN 0     0         0.0.0.0:68             0.0.0.0:*     
tcp     LISTEN 0     128       127.0.0.1:5432           0.0.0.0:*     
tcp     LISTEN 0     128       127.0.0.1:6463           0.0.0.0:*  
tcp     LISTEN 0     128       0.0.0.0:1729          0.0.0.0:* 

How can I complete the process?

EDIT 16.10.2019

Answer to connect on home PC to global IP home PC:

$ ssh Thomas@70.***.**.**        
ssh: connect to host 70.***.**.** port 22: Connection refused

Answer to connect on home PC to global IP remote PC:

$ ssh Tom@75.***.**.** 
ssh: connect to host 75.***.**.** port 22: Connection timed out.

Result of scan home PC global address:

$ nmap 70.***.**.**  -p 22
Starting Nmap 7.80 ( https://nmap.org ) at 2019-10-16 00:44 +04
Nmap scan report for 70.***.**.**
Host is up (0.00039s latency).

PORT   STATE  SERVICE
22/tcp closed ssh

Nmap done: 1 IP address (1 host up) scanned in 0.35 seconds

When I scan global IP address my remote PC I give similar answer, but STATE indicate as filtered.

4
  • Are you in power to configure network devices on the remote side? Or can you install software on the remote computer freely? Your question looks like your previous one in disguise, so the answers may be "no" and "no". The sooner it gets clear, the better. What about the local (home) side? – Kamil Maciorowski Oct 12 '19 at 22:54
  • Thanks for the answer. I want to note that I have all the authority to do whatever I want with both computers. – Atom Oct 13 '19 at 8:11
  • SSH server would need to be set up on the remote PC with the server's port configured for DNAT on the WAN facing router the PC is behind. The RFC1918 subnet the server and client are on has no bearing, as the incoming connection to the server is inbound from WAN and will be seen as a connection from the remote PC's router's WAN IP. Since a port is being passed directly to the PC from the router with no firewalling, it's imperative the SSH server is configured for PKI auth only, with password auth disabled. – JW0914 Oct 13 '19 at 12:30
  • Thank you very much for the detailed answer. Honestly, I know all my addresses, both local and global, both on a remote PC and on my home. See details above, I edited my question. – Atom Oct 14 '19 at 15:18
0

The address of the remote server cannot be 192.168.*.*. This address range is for "local" LANs. It actuall looks like this:

  • your computer is on a local lan, all the devices on that LAN are in the 192.168.. range.
  • One of these devices (usually 192.168.0.1 or 192.168.0.254) is a router. To communicate outside the local LAN devices on the LAN send the packet to the router.
  • The other side of the router is connected to the internet. On that side it has a real internet address (outside the 192.168.. and 10...* ranges).
  • When any device on your LAN connects to the internet it appears as having the internet address of your router (go to https://www.showmyip.com/ to see the address of your router).

This true on the other side, given the 192.168.. address, the server is also on a local LAN, so to communicate with it, you have to know the internet address of the router connected to its local LAN.

But this won't be sufficient, because:

  • routers are normally configured to only let outbound connections through (you can start connections with internet addresses, but the internet cannot start connections to you)
  • assuming they let in inbound connections, routers cannot tell which local device is the intended receiver, because all they have is an address (but that's their own address) and a port. Bu they can be configured to forward all connections to a specific port (for instance, 1749) to a specific machine on the local LAN.

TLDR; you need 1) the actual internet address of your server or its router and 2) make sure that the router is adequately configured to let the connection happen.

PS: in a connection, only the target port is important.

Edit:

To connect to the server from your home PC, you just need to know the internet address (75.xxx.xx.xx) of the server and the port (1729 it seems in your case, otherwise the standard SSH port: 22).

Of course you also need a SSH client. With the command-line SSH, this gives ssh -p 1729 Tom@75.xx.xx.xx, and enter Tom's password when prompted. You can also use a GUI client, such as PuTTY. Configuration is also minimal, it just requires a host name or address and optionally a port.

This is the basics, with suitable configuration you can avoid entering a password, or use a key-bases authentication (which is usually safer unless you use a very, very long password).

Note that the connection is always from your PC to the server.

Edit#2

Checking the server. On a typical server:

ss -nltu
Netid  State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
tcp    LISTEN     0      80     127.0.0.1:3306                     *:*                  
tcp    LISTEN     0      128          *:22                       *:*                  
tcp    LISTEN     0      100          *:25                       *:*                  
tcp    LISTEN     0      128         :::80                      :::*                  
tcp    LISTEN     0      128         :::22                      :::*                  
tcp    LISTEN     0      100         :::25                      :::*                  
tcp    LISTEN     0      128         :::443                     :::*                  

This command lists the listening ports. 25 is a mailbox, 22 is SSH, 80 & 443 are the HTTP server, 3306 is the MySql DB (but it accepts connections only from the local host). The ':::' sockets are IPv6, and ':' are IPv4.

20
  • Thank you very much for the detailed answer. Honestly, I know all my addresses, both local and global, both on a remote PC and on my home. See details above, I edited my question. – Atom Oct 14 '19 at 15:17
  • @Atom See edited answer – xenoid Oct 14 '19 at 15:49
  • Fine. Thank you very much for the answer, but I have answer questions. :) Please, see edited question. – Atom Oct 14 '19 at 17:09
  • @atom Try with the standard port (22). But then since the server seems to be behind a router is the router config adequate (port forwarding)? – xenoid Oct 14 '19 at 17:59
  • The same result. :( I cannot unambiguously answer whether port forwarding is correct. Could you tell me how I can check this and find out? – Atom Oct 14 '19 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.