Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
ssh-keygen -t rsa

Save the key in the default key and  leave the passphrase empty. This will generate a pair of public and private keys, with the default file names id_rsa and id_rsa.pub. Don't share or expose your private key.

...

You should be able to connect to the remote machine without being prompted for a password. Exit to your local machine using Ctrl+D

Create a ssh config file

 

To make it easier to connect to the remote machine in the future, you can create an or edit your ssh config file . This in  ~/.ssh/config. This file allows you to specify connection settings and aliases for different remote machines. To create an ssh config file, open the ~/.ssh/config file in a text editor and enter the following information, replacing user_id with your username on the remote machine:

Code Block
Host crc
    User user_id
    HostName gw.crc.rice.edu
    IdentityFile ~/.ssh/id_rsa

Host aries
    User user_id
    HostName aries.rice.edu
    ProxyJump crc
    Port 22
    IdentityFile ~/.ssh/id_rsa

Host nots
    User user_id
    HostName nots.rice.edu
    ProxyJump crc
    Port 22
    IdentityFile ~/.ssh/id_rsa

Save the file as ~/.ssh/config.

Connect Test the connection from you local machine to the remote machine using the alias. To  The gateway will be accessible without a password. You should be able to connect to the remote machine using the alias, gateway enter the following command in your terminal:

Code Block
languagebash
ssh crc

Exit to your local machine with Ctrl+D

Copy the keys to the compute servers

To add the keys to the compute servers add the keys from your local machine to ~/.ssh/authorized_keys in the compute machine. For that in your local machine get the public key by executing the following command:

 

Code Block
languagebash
cat ~/.ssh/id_rsa.pub

 

Connect from your local machine to the compute servers This will connect you to the remote machine using the settings and alias specified in the ssh config file . The gateway will be accessible without a password. Exit and try connecting to the compute servers:with the following command:

 

Code Block
languagebash
ssh nots

 

The compute server will still ask for a password. To connect to them without a password we will need to copy the keys to them too.

...

 

Copy the public key to the compute servers Enter the following commands in your terminal, replacing user with the correct rice user id:. In order to do that edit or create a file called ~/.ssh/authorized_keys and add the contents from your ~/.ssh/id_rsa.pub file in a new line.

Code Block
languagebash
ssh-copy-id aries
ssh-copy-id nots

This will copy your public key, id_rsa.pub, to the remote machine and add it to the authorized_keys file on the remote machine.

vi ~/.ssh/authorized_keys

Save the file and exit to your local machine with Ctrl+D.

To test Test the connection. Enter the following command in your terminal to connect to the remote machine:

Code Block
languagebash
ssh ariesnots

You should be able to connect to the compute servers without being prompted for a password.

...