- Generate ssh key
# Generate ssh key with files(~/.ssh/id_rsa, ~/.ssh/id_rsa/pub) and username in default
ssh-keygen -t rsa
# Generate ssh key with specified files and username
ssh-keygen -t rsa -f ~/.ssh/[KEY_FILENAME] -C [USERNAME]
- Install ssh key to server
ssh-copy-id -i ~/.ssh/id_rsa.pub user@host
ssh-copy-id -i ~/.ssh/mykey.pub user@host
It equals to manually add the public key to ~/.ssh/authorized_keys
- Test ssh login with the new key
ssh -i ~/.ssh/mykey user@host