How to set up ssh-keys to connect to a remote machine without password
I have done this so many times but without actually remembering how to do it properly. So here’s my personal note on how to do it. I took inspiration from the Github guidelines.
Check for existing keys
Navigate to the
cd ~/.ssh/ and type
ls -al ./ to list possible public SSH keys.
Public SSH keys should be named:
Generate a new SSH keys
- If you don’t have a public key yet, open a Terminal window (Bash Shell).
ssh-keygen -t rsa -b 4096 -C "email@example.com"indicating an email adress.
- This creates a new ssh key, using the provided email as a label.
- When you’re prompted to “Enter a file in which to save the key,” press Enter. This accepts the default file location.
Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
- At the prompt, type a secure passphrase. I prefer not to have one as it saves quite some time when connecting regularly to the same remote machine. It will prompt you:
Enter passphrase (empty for no passphrase): [Type a passphrase]. Type enter.
Adding your SSH key to the ssh-agent.
- Start the ssh-agent in the background. Type
eval "$(ssh-agent -s)".
- Add your SSH private key to the ssh-agent and store your passphrase in the keychain. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_rsa in the command with the name of your private key file. Type
ssh-add -K ~/.ssh/id_rsa.
- Copy the SSH key to your clipboard:
pbcopy < ~/.ssh/id_rsa.pub. If your SSH key file has a different name than the example code, modify the filename to match your current setup.
Adding your SSH key to the remote.
Please refer to this manual: https://help.github.com/en/articles/adding-a-new-ssh-key-to-your-github-account
- Login to genseq with your password.
- Go to
- Open the
id_rsa.pubfile (or create a public key name using the same name as on your machine). Type:
- Copy-paste the public SSH key (stored in your clipboard).
Please refer to https://userinfo.surfsara.nl/systems/lisa/user-guide/connecting-and-transferring-data