SSH is - secure server shell, that allows for us to interact with remove server, for example your VPS
The command:
ssh-keygen
The command generate pair keys public and private.
You can find the kays in your root directory in .ssh
folder, eg. /home/master/.ssh
It looks like this:
cd /home/master/.ssh
ls -la
drw------- 2 master master 4096 Feb 4 15:06 .
drwx------ 10 master master 4096 Apr 16 16:44 ..
-rw------- 1 master master 2602 Feb 1 09:38 id_rsa
-rw-r--r-- 1 master master 567 Feb 1 09:38 id_rsa.pub
id_rsa is your private key, the key must not fall into the wrong hands.
id_rsa.pub is public key, any one can take the key, and use to authorize you when you will try to connect to remote machine.
The command:
ssh-copy-id username@ip
In completed variant it can looks like:
ssh-copy-id [email protected]
After executing the command, you need to enter the password for the user you specified in the command above.
To get public key that can connect to the server you need to go to the .ssh directory, and run the following:
ls -la
drw------- 2 root root 4096 Feb 4 15:06 .
drwx------ 10 root root 4096 Apr 16 16:44 ..
-rw------- 1 root root 5499 Feb 4 15:26 authorized_keys
The file authorized_keys
file stores all the public keys that can log-in to the server.