Score:0

SSH from local machine to remote VM not working

bd flag

I'm new to SSH and I've successfully SSHed from local machine to local VM

now I'm trying to SSH into a VM which is hosted by a remote machine.

Here's the error:

vm@vm1-VirtualBox:~$ ssh my_local_name@192.168.***.**
ssh: connect to host 192.168.***.** port 22: Connection timed out

Here's what i have tried:

sudo ufw allow 22

sudo systemctl enable ssh

Both the local machine and the remote VM have client and host ssh, i have tried connecting local to remote VM and vice versa.

One thing i find weird is that ping does not work, i tried pinging the other machine with ping <IP> but it returns:

ping 192.168.**.*
PING 192.168.**.* (192.168.**.*) 56(84) bytes of data.
^C
--- 192.168.**.* ping statistics ---
10 packets transmitted, 0 received, 100% packet loss, time 9198ms

And service ssh statusreturns:

ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: e>
     Active: active (running) since Thu 2022-11-10 01:59:30 +08; 39min ago
       Docs: man:sshd(8)
             man:sshd_config(5)
   Main PID: 16543 (sshd)
      Tasks: 1 (limit: 9319)
     Memory: 1.8M
        CPU: 44ms
     CGroup: /system.slice/ssh.service
             └─16543 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

Nov 10 01:59:29 Ubuntu-X550CC systemd[1]: Starting OpenBSD Secure Shell server.>
Nov 10 01:59:30 Ubuntu-X550CC sshd[16543]: Server listening on 0.0.0.0 port 22.
Nov 10 01:59:30 Ubuntu-X550CC sshd[16543]: Server listening on :: port 22.
Nov 10 01:59:30 Ubuntu-X550CC systemd[1]: Started OpenBSD Secure Shell server.

checked my ip & username

Where could i have gone wrong ?

user535733 avatar
cn flag
192.168.*.* is a non-routable address. That means it CAN be used to connect A and B on the same local network. But it CANNOT be used if a router is between A and B (so not across the internet, which has stacks of routers).
user535733 avatar
cn flag
Usually this means that all the devices on a local network *share* a single internet (routable) IP address...the IP address of the gateway router. So B's LOCAL ip address might be 192.168.1.3, but the INTERNET ip address is really 123.456.789.012. That internet address is what A needs to use to find B.
Score:0
bd flag

After some answers given from you guys, here's the problem elaboration and answer/solution:

Problem:

I have insufficient knowledge about the process how SSH works. for those who encounter similar problem, I suggest you guys look up LAN and WAN.

Answer:

Basically, if you want to SSH into a remote machine that is on the same network (LAN), you do not have to configure your router.

BUT if you wish to SSH into a remote server that is not in the same network, you will need to configure the host's router (the remote machine you're trying to connect to), how to here.

After you setup your router to port forward to you host machine, you will have to get your router's public IP (WAN IP), more info here.

Finally, you can connect with ssh remote_name@remote_router_ip

GL !

Artur Meinild avatar
vn flag
Cheers! This is networking 101. Happy you learned something new! However, this hasn't really got anything to do with Ubuntu...
Fixel avatar
bd flag
yah, I just don't know where else to ask. can you point me to the right direction?
Fixel avatar
bd flag
but this is SUCH A GREAT COMMUNITY OMGAWD, y'all basically troubleshoot problems for free ! LOVE THIS COMMUNITY SO MUCH !!! I hope one day I can be just like you guys . . . troubleshooting for others ;)
Artur Meinild avatar
vn flag
I think [su] would be the best place to ask. If the question/answer relates to a device running Unix/Linux, also consider [unix.se]. But in general [su] has the widest scope.
Artur Meinild avatar
vn flag
Thanks, much appreciated.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.