Using Your Key¶
Adding Your Key to Remote Machine¶
To login to a computer using SSH keys, your pubilc key must be listed in ~/.ssh/authorized_keys
on the computer you
wish to log into. This can be done manually by logging into to the computer, then copying and pasting the key into
~/.ssh/authorized_keys
— creating the directory and file if they don't already exist.
Or, you can use the command ssh-copy-id {username}@{host}
, which asks you to login, and then does the rest for you!
The next time you try to connect, SSH will see your public key on the remote computer and check for the private key on your local computer. This means that you'll no longer need to enter your password when connecting!
Adding Your Key to GitHub¶
-
Copy the SSH public key.
Tip
If
pbcopy
doesn't work, open the file in the.ssh
directory with a text editor and copy it.- On https://www.github.com, click in the top-right on your profile picture, then select 'Settings'.
3. On the left, click 'SSH and GPC keys'.
4. Click 'New SSH key'.
5. Use the title field to write a descriptive name for the key. 6. Then paste the key in the 'Key' field. 7. Then click 'Add SSH key' to finish.
Requesting Outrigger Access to Sites and Nodes
Access to the CHIME Outriggers is passwordless; it uses SSH keys. To request access, please follow the instructions given at https://github.com/CHIMEFRB/outrigger-devops/wiki/User-Accounts.
Connecting With Your Key¶
The command ssh
is used to access other machines connected across a network, including the Internet. To call ssh
, we write:
Where username is the username of the account on the machine (host) that you'd like to access. This will result in a direct login if your public SSH key has already been added to the machine, or a prompt asking you to enter a password in order to allow the connection, if you have not yet added it, or encrypted your SSH key with a passphrase.
Never Copy Your Private Key to Public Computers!
In the case that you want to connect from A to B and then from B to C, although you can copy your key pair to B
and use it to connect to C, this is not recommended. Doing so increases the chances of a third party accessing your
keys. The same benefits can be achieved by adding your key to ssh-agent
and enabling agent forwarding by connectign with ssh -A
and then ssh-add
on the connected remote machine. Doing so essentially opens a socket to enables forwarding of the authentication agent connection. The value is then stored in $SSH_AUTH_STOCK
, which is useful as it can be used when running things like Dockerfiles or Git that can require your SSH key too.