Set up SSH on lab computers for passwordless login to the Lab computers
Open a terminal window on your computer. On Windows, you can use the Git Bash terminal that comes with Git for Windows. On Mac, you can use the Terminal application. On Linux, you can use the terminal application that comes with your distribution.
Type the following command in the terminal window:
ssh-keygen -t rsa
When prompted, enter a filename and location in which to save the key pair. For example, you can enter
~/.ssh/id_rsato save the key pair in the.sshdirectory in your home directory. You can also enter a passphrase to protect the private key. If you enter a passphrase, you will be prompted to enter it each time you use the key pair to log in to a remote computer.After the key pair is generated, type the following command to copy the public key to the remote computer:
ssh-copy-id username@jumpgate.scorec.rpi.edu
replace username with your RCS ID.
For windows,
ssh-copy-idis not available. You can manually copy the public key to the remote computer.- Open the public key file (e.g.,
~/.ssh/id_rsa.pub) in a text editor. - Copy the contents of the file to the clipboard.
- Log in to the remote computer with
ssh remote_name. - Open the
~/.ssh/authorized_keysfile in a text editor. And paste the contents of the clipboard to the end of the file. Save the file.
- Open the public key file (e.g.,
When prompted, enter the password for the remote computer. The public key will be copied to the remote computer and installed in the
~/.ssh/authorized_keysfile. You can now log in to the remote computer without entering a password.
Note: If it asks for a password even after following the above steps, it might be due to the permissions on the .ssh directory or the authorized_keys file. Make sure the permissions are set correctly as follows:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
this problem is relatively rare though.
Another common problem is the key is not added to the ssh agent or the agent is not running. The follwing steps can be followed to add the key to the agent and start the agent (for windows you need to use elevated powershell, i.e. run as administrator.):
# By default the ssh-agent service is disabled. Configure it to start automatically.
# Make sure you're running as an Administrator.
Get-Service ssh-agent | Set-Service -StartupType Automatic
# Start the service
Start-Service ssh-agent
# This should return a status of Running
Get-Service ssh-agent
# Now load your key files into ssh-agent
ssh-add $env:USERPROFILE\.ssh\id_ed25519
On Linux you can use the following commands to start the agent and add the key:
# start the agent
eval `ssh-agent -s`
# add the key
ssh-add ~/.ssh/id_rsa
The first command can also be added to the .bashrc file so that the agent is started automatically when you open a terminal.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.