Select Your OS:
Once you've generated an SSH key on your local machine, you're going to want to use it to securely access your remote servers in the cloud (or server room). Make sure to go through the prerequisites if you aren't familiar with SSH key generation.
- A 32-bit or 64-bit computer with at least 8GB of RAM. 16GB or more is recommended.
- A virtual machine or remote server running Ubuntu 14.04.
You'll need the server's IP address. You'll also need the credentials of a user on the server in order to sign in to the machine for the first time. So if you were to try to ssh into the machine now, without having uploaded the public key, you'd receive the following output and be prompted to enter the user's password.
user with the external server user's username and
my.external.server.ip with the external server's IP address.
ssh firstname.lastname@example.org email@example.com password:
Now that we're able to access our remote machine using our username and password, we'll want to make use of our SSH key, which will allow us to access the remote machine with just our username.
- Run the following commands on the remote machine, which should be running Ubuntu 14.04 LTS.
- Now you'll want to paste the public key you copied from PuttyGen into the
~/.ssh/authorized_keysfile on the remote server or virtual machine.
- Now, exit the remote server, by running
exitfrom the terminal, and run the following command, from your local machine, which will append your public key to the remote machine's
authorized_keysfile. If you're using a VM, run:
cat ~/.ssh/id_rsa.pub | ssh firstname.lastname@example.org "cat >> ~/.ssh/authorized_keys" ssh email@example.com
cat ~/.ssh/id_rsa.pub | ssh firstname.lastname@example.org "cat >> ~/.ssh/authorized_keys" ssh email@example.com
- Moving forward, when SSHing into the remote machine, you should not be prompted for a password.
sudo adduser user [sudo] password for ubuntu: Adding user `user' ... Adding new group `test' (1002) ... Adding new user `test' (1002) with group `user' ... Creating home directory `/home/user' ... Copying files from `/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for user Enter the new value, or press ENTER for the default Full Name : Room Number : Work Phone : Home Phone : Other : Is the information correct? [Y/n] Y
/etc/hosts and add the following line:
my.external.server.ip with the server's actual IP address. Replace
myserver with anything you'd like.
Now you can ssh with
Now that you know how to SSH into a remote server, you can repeat these steps on any number of remote servers. You can even SSH from one remote server to another. Feel free to experiment with this by setting up a second virtual machine.