If you have hypervisor software installed (such as VMWare Workstation of VirtualBox), it’s convenient to have the ability to connect to a running virtual machine instance from your local client using ssh. In this post, we’ll demonstrate how to setup ssh connectivity from a Windows client to a virtual instance of Ubuntu 17.04 running on VMWare Workstation. It is assumed that either PuTTy or Cygwin are installed on the local Windows client, and that Ubuntu 17 has been setup and is available for use through the VMWare Workstation interface.

To begin, boot into Ubuntu 17 from WMWare Workstation. Once loaded, run the following from the terminal:

$ sudo apt install openssh-client


Followed by:

$ sudo apt install openssh-server


Once installed, we’ll need to modify a few settings in /etc/ssh/sshd_config. From the terminal, navigate to /etc/ssh. Make a copy of sshd_config with the current date and a .bak extension:

$ cd /etc/ssh
$ cp sshd_config sshd_config_YYYYMMDD.bak


Next, open sshd_config in your editor of choice. There are 3 settings we should change: The Port, PermitRootLogin and AllowUsers (which may not be present):

# Port 22
# PermitRootLogin yes
# AllowUsers jtrive84


We can change the ssh port to something other than 22 in sshd_config. For this example, let’s change the port to 3337. In addition, we should set PermitRootLogin to no, and if not present, add AllowUsers, followed by your username only. If the comment character preceeds a particular setting, be sure to remove it so the change can take effect. Assuming the primary user’s username is user1, after making the changes, the settings should read:

Port 3337
PermitRootLogin no
AllowUsers user1


In order to connect to your virtual instance via ssh, you’ll need to set its networking mode to bridged. This can be accomplished using the VMWare Workstation interface. Navigate to Player > Manage > Virtual Machine Settings > Network Adapter, then on the right side select Bridged: Connected directly to the physical network. Once set, restart the virtual instance.

To determine whether the changes to sshd_config we recognized, open the terminal and run the following:

$ sudo service ssh start
$ sudo service ssh status


You’ll see something similiar to:

ice - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2017-12-01 12:13:54 CST; 1h 2min ago
 Main PID: 848 (sshd)
    Tasks: 1 (limit: 19660)
   CGroup: /system.slice/ssh.service
           └─848 /usr/sbin/sshd -D

Dec 01 12:14:06 ubuntu sshd[848]: Server listening on :: port 3337.


Notice that on the last line, we receive confirmation that the server is listening on port 3337, which means our changes have been recognized by the service. We will target port 3337 when connecting to the virtual machine from our local client.
We need one final piece of information prior to connecting: The local IP address associated with our virtual instance. This can be obtained by running the following command and searching for inet:

$ ifconfig -a


Alternatively, you can run this command:

$ ip route get 8.8.8.8 | awk '{print $NF; exit}'


For the purposes of demonstration, assume the virtual instance’s local IP address is 192.168.0.12.
Back on the local client, open Cygwin. As earlier, assume that the username for the virtual instance is user1. To login to Ubuntu, run:

$ ssh -p 3337 user1@192.168.0.12


The -p 3337 specifies the target port for ssh. user1 is the username, and 192.168.0.12 is the IP address of the virtual instance. Note that this IP address is not static: It will change with each system reboot.