Table of Contents

SSH Client and Server

To login to any machine with SSH, you need to install the ssh server. The client is installed on Debian Wheezy by default. This guide sets up SSH access for BackupPC, but you can use it for any other user respectively. You can find further information in the BackupPC FAQ: SSH Setup.

Important!

After creating the authorized_keys file with the public keys of root@myserver and backuppc@myserver, ssh to the client as root and as backuppc. User backuppc will not be able to establish a connection, but the client's key will be added to known_hosts. This is necessary for BackupPC to work correctly.

SSH Server

apt-get install ssh

Running ssh-keygen as root will install the host keys, ssh-keygen as <user> the keypair into directory ~/.ssh. The private key file, e.g. ~/.ssh/id_rsa needs to be copied to all clients which need access to the server, the public key file, e.g. ~/.ssh/id_rsa.pub, needs to be added to the authorized_keys file of the server to allow access to the server. In addition, you should adjust the access rights for the different files and directories. As <user>, enter the following commands

On the client:

ssh-keygen
ssh -vvv -p <port#> <servername> // check the ssh connection
sftp -oPort=<port#> <servername> // transfer the public key file
sftp > put client_id_rsa.pub

On the server:

sudo cat client_id_rsa.pub >> ~/.ssh/authorized_keys

Make sure permissions and ownership are set correctly:

sudo chmod 700 ~/.ssh
sudo chmod 600 ~/.ssh/*
sudo chown -R user:user ~/.ssh

Check the ssh access:

ssh <servername> whoami // needs to return the username under which the ssh access was established, e.g. user1
ssh -l root <servername> whoami // needs to return "root", as this establishes the ssh access as root, not as user1
ssh -vvv -p <port#> -l root <servername> whoami // same as above, but use different port number with full debug verbose output

Important

You might need to include the user in sshd.conf to authorize access.

PuTTY as client

When you are working with private (and public) keys generated by OpenSSH, you will have files called id_rsa and id_rsa.pub. These files can't be used in PuTTY directly. Instead they need to be converted to something else using PuTTYgen, also available from the Putty page.

Host keys

How to reset host authentication key for known_hosts

If you receive RSA host key for foo.bar has changed and you have requested strict checking , do the following:

If you run Secure Shell app in the Chrome Browser to establish a SSH connection, do the following:

Aliases

Define an alias for frequently used ssh connections:

$ echo "alias <compname> 'ssh -p <port> <compname>'" >> vim ~/.bash_aliases