Secure Socket Shell commonly called SSH is a protocol that allows you to securely connect to a remote computer using the command-line interface(CLI). It’s so easy to set up and eliminates the need for manual logins.
Some of the reasons why you may be interested in setting up SSH are:
- You are a System admin, DevOps, or Backend engineer who wants an easier method to access your remote server or computer
- Or maybe you just want to learn how to do this for fun. No knowledge is a waste, and this may come in handy someday
This short article explains how you can quickly set it up an SSH connection to your remote machine.
Before starting with the setup procedure, please make sure you have the following:
- Basic knowledge of the command line i.e bash
- Local computer (your computer)
- Remote computer
- Network connection via the internet or LAN to the remote computer
On your local computer
On your local computer, open up a terminal and do the following steps.
- Check if you have an existing ssh key
ls -ll ~/.ssh
If you already have SSH keys on your local computer you should see a file with one of the following names
Id_rsa.pub id_ecdsa.pub id_ed25519.pub
- If you do have SSH keys skip to the next step. But if you don’t, generate a new key by running the following command:
ssh-keygen -t ed25519 -C "put_your_email_address_here"
You should get a prompt saying:
Enter a file in which to save the key. Press the
Enter Key on your keyboard to use the default file location or enter a custom file name.
Then follow the prompt if you’d like to set a passphrase for your SSH key. You can skip this by hitting the
Enter key twice.
- Next, shart the SSH agent:
eval "$(ssh-agent -s)"
- Then add your private key to the ssh-agent by running the below command. But If you supplied a custom file name(in step 2), replace id_ed25519 with it.
- Lastly, copy the contents of the public SSH key to your clipboard. You can use the
catcommand to print out its content and then copy the output from the terminal:
Awesome! Now you have everything set on your local computer. Let’s move on to set up the remote computer.
On the remote computer
Login into your remote computer and do the following steps on the terminal.
cdinto your SSH directory:
- Add your copied SSH key (from your local computer) to the
echo “put_your_public_ssh_key_here” >> authorized_keys
- Restart the SSH service
sudo systemctl restart ssh
Now, you’re done setting up your remote computer. All you have to do is to connect to your remote computer from your local computer.
Connecting to your remote computer
To connect to your remote computer, open a terminal on your local computer and run the code below and you should be connected:
Congrats you made it!
And that’s how to connect to a remote computer over SSH.
If you found this article helpful please leave a like. Also, check out my awesome Youtube channel where I do all sort of fun tech stuff
Top comments (0)