Accessing the VM through SSH

Although it is possible to enter in any configuration commands directly to the VM's command line console, many users find it easier to SSH (Secure Shell) to the VM and type commands through the command line on their host OS. Below are the general steps and commands to access the VM through SSH.

Step 1: Log in

Log into the VM as the system user with the name and password shown at the top of the VM upon start up.


Step 2: Generate SSH keys on the VM

Now that you're logged in, the SSH keys to access the VM need to be generated. Type the following commands, filling in for the text between the brackets:

mkdir -p .ssh

cd .ssh

ssh-keygen -f '<filename for SSH key>' -C '<comment for file>' -N '' -t rsa

This should generate two files, a private SSH key with the name that you entered for it, and a public key as well (ending in .pub). Now add the keys that you generated to the VM's list of authorized keys with the command:

cat <your public SSH key>.pub >> authorized_keys


Step 3: Move the keys to a space you can access from your host OS

Now that you have generated the keys, you will need to access them from your host OS. To achieve this, the following commands will place the SSH keys in a place on the VM that you will be able to retrieve from your host OS via SFTP.

sudo mkdir /sftp/transfer/data/keys

sudo mv /home/system/.ssh/<private SSH key> /sftp/transfer/data/keys

sudo mv /home/system/.ssh/<public SSH key>.pub /sftp/transfer/data/keys

sudo chmod 644 /sftp/transfer/data/keys/<private SSH key>

sudo chmod 644 /sftp/transfer/data/keys/<public SSH key>.pub


Step 4: Retrieve the keys from your host OS

The keys have now been generated and stored in a place that can be accessed by the host OS, so the last step is to pull them down and SSH to the system via the following commands:

sftp -P <22 or 2222 depending on your system> transfer@<IP or Hostname of your VM>

<enter transfer password> This password is available on the login screen in the VM console at startup.

cd keys

get <private SSH key>

get <public SSH key>.pub

exit

The keys will now be stored in your working directory on your Host OS. To see where those files are located, type lpwd. The downloaded private key needs to be changed to be read-only by just your user and unreadable by any other users on your system. On OSX or Linux, the command to run locally is:

chmod 600 <private SSH key>

The final step is to SSH to the system using this command and the newly downloaded key:

ssh -p <2222 or 22> -i <path_to_private_key> system@<IP or Hostname of your VM>

After a successful SSH connection is established, it is advised that you log into the VM as the system user (as described above) and delete your SSH keys from the directory /emcien_feed/data/keys.

Step 1: Log in

Log into the VM as the system user with the name and password shown at the top of the VM upon start up.


Step 2: Enable Password Authentication on the VM

Now that you're logged in, change the SSH configuration files on the VM:

sudo nano /etc/ssh/sshd_config

Change password authentication (around line 50) to 'Yes' then save the file.

This will enable password authentication on the VM. Restart the SSH service.

sudo service ssh restart


Step 3: From your computer's command line login to the VM

Now that you have enabled password authentication on the VM, login from your computer.

ssh -p 2222 system@localhost

Then enter the VM's password