How to setup and deploy ssh keys under linux?

Not a hard working, and there are already many articles talk about that, but many students still don’t know how to do that …

The simple syntax for generating ssh key pair:
$ ssh-keygen -t algorithm -b bits -C "comments"

For example:
$ ssh-keygen -t rsa -b 4096 -C "my first ssh key pair!"

The simple syntax for deploying ssh key:
$ ssh-copy-id [email protected]

For example:
$ ssh-copy-id [email protected]

If you also have problems with ssh keys, I will suggest you to read the articles below, they are confirmed by myself, I think those are correct and easy versions, and there is no need to write them in my blog again …

3 good articles should be enough …

Retrieve/regenerate ssh public key from private key

SSH public key can be retrieved from the private key if it’s lost.

From man page of ssh-keygen:

-y This option will read a private OpenSSH format file and print an OpenSSH public key to stdout.

ssh-keygen -y [-f input_keyfile]


$ ssh-keygen -y -f ~/.ssh/id_dsa > ~/.ssh/