setting up ssh keys for passwordless login
Users can set up ssh key auth in order to avoid having to type in a password at every ssh login. The process to do this varies from platform to platform, but there are steps common to all.
Step-by-step guide
From a linux or mac workstation:
- Generate your ssh keypair by entering 'ssh-keygen -t rsa' in the terminal. Press enter through the prompts. A passphrase to protect your ssh key is optional . If you opt to use a passphrase, you will have to enter it when authenticating with your ssh key (and some would say this defeats the purpose of using keys for passwordless login).
- Upload your public key to your home directory on DASH by entering 'scp id_rsa.pub <NetID>@dash.duhs.duke.edu:/home/<NetID>' - replace <NetID> with your actual NetID. Never share your ssh private key (id_rsa).
- Log in to DASH via ssh: 'ssh <NetID>@dash.duhs.duke.edu'
- Add your workstation's public key info to your authorized_keys file on DASH: 'cat id_rsa.pub >> ~/.ssh/authorized_keys' . If you get an error that this file does not exist, create the needed ~/.ssh content by following the same 'ssh-keygen' steps you followed to generate keys on your workstation, then repeat the 'cat' step.
- After saving your modified ~/.ssh/authorized_keys file, exit out of your ssh session and reconnect. On reconnect you should not be prompted for your password (unless you opted to use a passphrase for your ssh key).
The same basic processes apply when using a Windows workstation, but will vary depending upon the ssh client used (putty versus git bash versus Windows Subsystem for Linux, etc).
Related articles