SSH to virtual machine works only in one specific way

I have Ubuntu 20.04 installed on VMware Workstation 16 Player. I installed SSH server. To test it I did not use any key-pair, but only password.
From the Windows host the only way I can SSH into the machine is by using the command ssh username@<LAN IP address*>. *address as seen in ip a command on Ubuntu near inet

If I try to use the same command from another PC I will get ssh: connect to host localhost port 22: Connection timed out. (But that’s obvious, because the IP is internal for the same network of the virtual machine and the Windows host)

But, If I try to use ssh username@localhost (from the Windows host)I get “ssh: connect to host localhost port 22: Connection refused”

Also, If I try to use ssh username@<public IP address> I get ssh: connect to host localhost port 22: Connection refused

To sum it up, the only way I can SSH to this virtual machine is from the host it runs from, and only using ssh username@<LAN IP address*>
*address as seen in ip a near inet

How to fix it? how to be able to SSH to it from other PCs on the internet as well?

Thanks


Go to Source of this post
Author Of this post: pileup
Title Of post: SSH to virtual machine works only in one specific way
Author Link: {authorlink}