Setting up SSH


SSH stands for Secure Shell and it’s a network protocol for secure remote connections (command line). By default it operates on Port number 22.

The SSH-client usually comes with in the distribution, so you don’t have to install it separately, but if you need to install it.

Install SSH-client to Debian

sudo apt install openssh-client

Install SSH-client to Arch Linux

sudo pacman -S openssh

To make a remote connection

ssh username@domain-or-ip-address

SSH is crucial and extremely useful tool, when you are running Raspberry Pi or VPS.

Generate your first SSH key(s)

SSH keys comes in handy when working with for example GitHub.

Generate the keys with the following command,

ssh-keygen -o -t rsa -b 4096 -C "your-email@adress"

The keys are stored in .ssh folder inside your home folder.

/home/<username>/.ssh

When you run the ssh-keygen command. There are now two new keys in the .ssh folder. The keys are:

  • id_rsa
  • id_rsa.pub

The first key is private and the second key is public.

You should never share your private key to anyone.

Create an account or log into Github. On the top right corner, click on your profile and choose settings from the drop down menu.

Go to SSH and GPG Keys and click the New SSH key button on the top right corner.

Give your key a name (or a title) and in the key text box, you need to copy and paste the id_rsa.pub file content. To do that, you can use the following command on your home folder,

cat .ssh/id_rsa.pub

The file starts with ssh-rsa then there is a very long random string and ends up with your email address.

Copy all that to the GitHub’s key text box and click Add SSH key button. Now you are good to go!