uog logo
School of Physics and Astronomy – computing
phas it logo

Contents

Installing SSH keys (sometimes)

The instructions below are for information only, and are not how you install keys on a P&A system. For that, see the main ssh instructions.

Many (most?) online services that use SSH keys for access (one prominent example is github) require you to lodge your key with them via a web interface, just as we do in P&A. But there is an older, by-hand method which you may encounter.

Using .ssh/authorized_keys §

When you plan to connect to a non-P&A remote machine, mymachine.example.edu, on which your username is myname, you must first copy the public key file (ie, the one named .pub) to the remote machine:

$ scp ~/.ssh/id_ed25519.pub myname@mymachine.example.edu:.

or similar (notice that the final :. is part of the command), then ssh to that machine and append that id_ed25519.pub file to the end of the file ~/.ssh/authorized_keys, creating the file if necessary. This file must have mode 600, so you may need to use chmod to adjust it.

mymachine$ mkdir .ssh   # if this doesn't already exist
mymachine$ chmod 700 ~/.ssh
mymachine$ cat id_ed25519.pub >> ~/.ssh/authorized_keys
mymachine$ chmod 600 ~/.ssh/authorized_keys
mymachine$ rm id_ed25519.pub

To check:

mymachine$ ls -ld .ssh
drwx------  2 norman  staff  4096 14 Apr 10:44 .ssh/
mymachine$ ls -l .ssh
-rw-------  1 norman  staff  804  1 Mar  2017 .ssh/authorized_keys

You only need to do this once per remote host.

Check you've done everything correctly by ssh-ing in using only your key. Use ssh -v to show more detail.

Getting the permissions wrong on the ~/.ssh/ directory or its contents, is a common mistake: mode 700 on the ~/.ssh directory, and mode 600 on the files, should be OK.

Using ssh-copy-id §

This is a faster method, if it's available for you.

If your ssh installation includes a command ssh-copy-id, then you can automate the above instructions with

ssh-copy-id -i ~/.ssh/id_ed25519.pub myname@mymachine.example.edu