How to Create an SSH Key Pair for User Authentication

Create key pair using different algorithms

$ ssh-keygen -t rsa -b 4096
$ ssh-keygen -t dsa
$ ssh-keygen -t ecdsa -b 521
$ ssh-keygen -t ed25519

Specify a file name while creating the key pair

$ ssh-keygen -f ~/.ssh/rdu_github -t rsa -b 4096

Typically you want the permissions to be:

  • .ssh directory: 700 (drwx——)
  • public key (.pub file): 644 (-rw-r–r–)
  • private key (id_rsa): 600 (-rw——-)