How to SSH Into an External Server

2020-07-15 12:30:45 | #sysadmin

Tested On

  • Linux Ubuntu 20.04

The following guide will teach you how to use the terminal to access a remote computer, server, or virtual machine over SSH, eliminating the need to enter a password, every single time.

This is extremely convenient when you find yourself needing to log in to an external server, frequently. For a server to qualify for SSH access, you must already be able to remotely access it with a username and password. You must also have the proper permissions to upload a public key.

Generating the Private and Public SSH Key Pair

Run the following command on your local shell/terminal, substituting in your own email address.

ssh-keygen -t rsa -C ""

This will generate a series of prompts. For tutorial purposes, just hit enter for all the default values that are presented. This will generate a key pair in your /home/user/.ssh/ directory.

Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa.
Your public key has been saved in
The key fingerprint is:
52:e6:74:09:89:96:13:80:c4:41:5f:a9:1f:14:cd:33 myuser@My-Computer
The key's randomart image is:
+--[ RSA 2048]----+
| ++o..+O..       |
|  o. .B E. .     |
|    .+ .+oo      |
|    . .= .       |
|     ...S        |
|      ..         |
|                 |
|                 |
|                 |

Accessing the Server

Next, you'll need the server's IP address and the credentials of a user on the server in order to sign in to the machine for the first time. If you were to try to SSH into the machine, now, without having uploaded the public key yet, you'd receive a prompt to enter the user's password.

Let's sign in by running ssh user@serverip (substitute your username on the server and the server's IP address) and set up the necessary files on the server. Next, create a user for yourself with the following commands. Enter a secure password when prompted.

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 []: Name
 Room Number []:
 Work Phone []:
 Home Phone []:
 Other []:
Is the information correct? [Y/n] Y

Now, log out of the server with the exit command. Once you've run the following command which will append your local public key to the remote server's authorized_keys file:

cat ~/.ssh/ | ssh user@server "cat >> ~/.ssh/authorized_keys"

Now, when you ssh into the server, you won't need to enter your password. Try it out yourself by running ssh user@server.


That's the end of this tutorial. We hope you found it helpful. Make sure to check out our other tutorials, as well.


You must log in to comment. Don't have an account? Sign up for free.

Subscribe to comments for this post

Want To Receive More Free Content?

Would you like to receive free resources, tailored to help you reach your IT goals? Get started now, by leaving your email address below. We promise not to spam. You can also sign up for a free account and follow us on and engage with the community. You may opt out at any time.

Hire Us for IT and Consulting Services

Contact Us

Do you have a specific IT problem that needs solving or just have a general IT question? Use the contact form to get in touch with us and an IT professional will be with you, momentarily.


We offer web development, enterprise software development, QA & testing, google analytics, domains and hosting, databases, security, IT consulting, and other IT-related services.

Free IT Tutorials

Head over to our tutorials section to learn all about working with various IT solutions.

We Noticed Adblock Running

Because we offer a variety of free programming tools and resources to our visitors, we rely on ad revenue to keep our servers up. Would you consider disabling Adblock for our site and clicking the "Refresh Page" button?