How to SSH into Vmware player/Virtual Box guest Linux OS remotely(host OS is Window 10)
All credits go to https://hitchhikingtheweb.wordpress.com/2014/09/02/portforwarding-with-vmware-player-and-nat/
Virtual Box has a quite friendly UI to do so, just go to Settings-> Network -> Adapter<n> , click “Port Forwarding”. Configure a NAT rule, for instance:
name: external SSH incoming
protocol: TCP
Host IP: <Your Windows public IP>
Host port: The port the remote SSH connects to, for instance, 2244
Guest IP: The IP of your guest OS
Guest Port: it’s TCP 22 for SSH
That’s it for Virtual Box. Now, you can SSH to your VirtualBox Guest VM from remote host using the command:
ssh -p 2244 <username>@<your windows 10 IP>
But Vmware Player is a bit not friendly enough. To achieve the same,
- Find this file C:\ProgramData\VMware\vmnetnat.conf
- Open and edit it with Administrator permission
- In [incomingtcp] section, add one line:
2244 = <your Guest OS IP>:22 - Save the file
- Run Windows command to restart vmware NAT service:
net stop “VMWare NAT Service”
net start “VMWare NAT Service”
Now, you can SSH into your Guest OS from your Host OS with the command:
ssh -p 2244 <username>@localhost
However, you cannot SSH to the Guest OS from another host yet, it’s because the Windows Firewall rules.
Open Control Panel -> Windows Defender Firewall -> Advanced settings. New an ‘Inbound Rules’.
- Select ‘Port’ as rule type. Next
- Select TCP and set the port “2244”
- Save
Now, you can SSH to your Guest OS on Win 10 from another host, for instance:
ssh -p 2244 <username>@<your win10 IP>