SSH keypair setup on the XS

SSH into the XS with a keypair

Here’s how I did it for my Ubuntu desktop client and the XS 0.6.

First, on the XS, uncomment these lines in /etc/ssh/sshd_config and

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile    .ssh/authorized_keys

Restart the ssh service

service sshd restart

Now generate keys on your client machine.


You might have to add -t rsa to that.

Sometimes you’ll have to do this as well, but not on the XO:


On the client machine, set the appropriate permissions in your home directory:

.ssh = 700
.ssh/id_rsa = 600

Copy .ssh/ on the client over to .ssh/authorized_keys on the XS.  Make sure it’s all in one line.  From the client, this should work, if .ssh/authorized keys already exists on the remote machine.

cat ~/.ssh/ | ssh -p <port> user@server ‘tee -a .ssh/authorized_keys’

On the XS, set the appropriate permissions in your home directory:

.ssh = 700
.ssh/authorized_keys = 644

Now you should be able to ssh into the XS without having to supply a password.

To make things even easier, especially if you’re using a nonstandard port and/or your username on the server is different from your username on the client machine, you can put an entry in ~.ssh/config

Here’s an example of my /home/anna/.ssh/config

Host schoolserver
    User anna
    Port 1985
    ServerAliveInterval 30
    ServerAliveCountMax 120

If you get an error about bad permissions when you use an ssh config file, simply

chmod 600 ~/.ssh/config

So now to ssh, all I have to do is:

ssh schoolserver

To scp, all I have to do is:

scp file.txt schoolserver:/home/anna

In ~.ssh/config, Host can be anything and Hostname can point to an IP.  It doesn’t have to be a domain name.

Leave a Reply