Generate Private/Public key pair for SSH connection on MacOS / Linux
1. use keygen on Client PC to generate ed25519 key pair stored in ~/.ssh/, their default name are id_ed25519 and id_ed25519.pub, and the account names on Client PC and Server are the same. # .pub is public key and non .pub is private key
$ ssh-keygen -t ed25519 #you should setup a passphrass
2. check and copy the public key to remote server
$ ssh-copy-id -n YourAccount@YourServer # YourAccount stands for the account names on Client PC and Server, -n: try run
$ ssh-copy-id YourServer
3. connect by ssh tunnel form client to Server as figure 1.
$ ssh YourAccount@YourServer # authenticate with passphrass only, not account password on Server
(Figure 1.)
4. Finally, if you want to passwordless login with ssh, empty passphrase while executing ssh-keygen processing
References
LPIC-1 STUDY GUILDE, SYBEX