Skip to content

SSH Basics


On Debian-based systems the SSH server can be installed as follows:

apt install openssh-server

In contrast, on Arch-based systems the SSH server can be installed as follows:

pacman -S openssh

Furthermore, you need to enable and start the sshd daemon:

systemctl enable sshd.service 
systemctl start sshd.service 

Client usage

To connect to a server, run:

ssh -p port user@server-address

Public key authentication

To create a ssh key pair (i.e, public & private ley) of type rsa and with a custom bit length, we can use the following command:

ssh-keygen -t rsa -b 4096

Afterwards, you should add your private ssh key to the ssh-agent so the key is known to your system:

ssh-add ~/.ssh/id_rsa

You can copy the public key into the new machine's authorized_keys file with the ssh-copy-id command.

ssh-copy-id user@host

Or you can use scp:

scp ~/.ssh/ user@host:~/home/user

And then on the remote machne you can cat the key to auhorized_keys:

cat  >> ~/.ssh/authorized_keys