SSH

creating a ssh key

ssh-keygen -t rsa -C "my server"

set a path where it should save

1. picture

confirm 2 times with enter so no password is set

2. picture

the key is now generated

3. picture

connect to your server using your normal password

ssh root@myip

create the .ssh folder

mkdir ~/.ssh

4. picture

open ~/.ssh/authorized_keys using nano

nano ~/.ssh/authorized_keys

5. picture

copy your public key from the .pub file (in this example my-server.pub) and paste it into the ssh session

6. picture

close nano by pressing ctrl + X

7. picture

confirm with Y

8. picture

confirm with Enter

open the sshd (ssh deamon) config file using nano

nano /etc/ssh/sshd_config

9. picture

enabling using ssh key by removing the # Infront of PubkeyAuthentication yes

before:

#PubkeyAuthentication yes

after:

PubkeyAuthentication yes

disabling the password usage by replacing yes with no in at PasswordAuthentication

before:

PasswordAuthentication yes

after:

PasswordAuthentication no

close nano once again using CTRL + X, confirming with Y, and then confirming with enter

restart sshd

service sshd restart

10. picture

exit the ssh session

exit

11. picture

connect again using the ssh key

ssh root@myip -i my-server

11. picture

now everything is done, auth over password isn’t possible anymore and your server is secured using an ssh key.