Create SSH Key on my server

Hello everyone, I hope you are doing well.

I would like to switch from user / password login on my linux server, to login without password by using a public SSH Key. The command I will use to create my key is:

ssh-keygen -b 4096 -t rsa -f filename

My question is, what’s the safe way to do it for me to try it first, and then to export/send this key to everyone to start using it?

Also, after I create the key with the command above, how can I enable the server to use it only for me in this first stage?

Any comment is highly appreciated. Thank you

Best regards,

It’s quite easy:

ssh-copy-id -i <file_name_which_is_your_public_key> user@server_ip

user is the name of the user you’re trying to use the public key with.


vim /etc/ssh/sshd_config

Scroll or search for PubkeyAuthentication yes and uncomment it.

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki