SSH Service Security

SSH Login With RSA Keys

Copy Public Key to The Server

ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]

Or Do It Manually :

ssh to the host (do not close this connection)

mkdir -p ~/.ssh && touch .ssh/authorized_keys

copy your public key usually located at ~/.ssh/id_rsa.pub

echo PUCLICK_Key_STRING >> ~/.ssh/authorized_keys

Configure sshd Service

edit /etc/ssh/sshd_config change:

#PasswordAuthentication yes

to

PasswordAuthentication no

save&exit

restart ssh service:

sudo systemctl restart ssh

Open New SSH Season and Test RSA Login


Optional: change ssh port

edit /etc/ssh/sshd_config change the port to a desired one

port 1337

save&exit

restart ssh service:

sudo systemctl restart ssh

Add Privet id_rsa key to Server

copy the id_rsa key to ~/.ssh folder

cd ~/.ssh
sudo ssh-agent bash
ssh-add id_rsa

Open New SSH Season and Test RSA Login

ssh [email protected] -p <port>

example:

ssh [email protected] -p 1337

Comments