How To:Set up transport encryption with SSH: Difference between revisions

From wiki.zmanda.com
Jump to navigation Jump to search
 
(11 intermediate revisions by 5 users not shown)
Line 1: Line 1:
===Backup process [[amdump]]===
{{How To Header}}
* You must create an ssh key for the Amanda server, and make sure you just hit enter when asked for a key passphrase. In this example, the key is put in the id_rsa_amdump file (Run as backup user - amandabackup):
SSH provides transport encryption and authentication. To set up an SSH authentication session, Amanda will run the equivalent of:
/path/to/ssh -l <CLIENT_LOGIN> client.zmanda.com $libexecdir/amandad
to start the backup process.
 
To do so, you need to set up ssh keys either by storing the passphrase in cleartext, using ssh-agent, or using no passphrase at all.  All of these options have security implications which should be carefully considered before adoption.  This article describes setting up SSH keys with no passphrase.  It should be fairly easy to adapt it to the other options.
 
When you use a public key on the client to do data encryption (see [[How To:Set up data encryption]]), you can lock away the private key in a secure place.  Both, transport ''and'' storage will be encrypted with such a setup.  See [[encryption]] for an overview of encryption options.
 
= Setup =
First, set up passwordless login between the amanda server and all clients.  This requires two things: distributing SSH keys and setting up host keys.  This page details the SSH configuration; the Amanda configuration is described authoritatively in {{man|7|amanda-auth}}.
 
== SSH Keys ==
Create an ssh key for the Amanda server, and make sure you just hit enter when asked for a key passphrase. In this example, the key is put in the id_rsa_amdump file (Run this as the backup user - ''amandabackup'' or ''amanda''):
   $ ssh-keygen -t rsa -C "SSH Key for Amanda Backups"
   $ ssh-keygen -t rsa -C "SSH Key for Amanda Backups"
   Enter file in which to save the key (/home/amandabackup/.ssh/id_rsa)? /home/amandabackup/.ssh/id_rsa_amdump
   Enter file in which to save the key (/home/amandabackup/.ssh/id_rsa)? /home/amandabackup/.ssh/id_rsa_amdump


* You must set the ssh_keys option in all DLE for that host:
Enable SSH authentication and set the ''ssh_keys'' option in all [[DLE]]s for that host by adding the following to the DLE itself or to the corresponding dumptype in [[amanda.conf]]:
  auth "ssh"
   ssh_keys "/home/amandabackup/.ssh/id_rsa_amdump"
   ssh_keys "/home/amandabackup/.ssh/id_rsa_amdump"
Note that ''ssh_keys'' is the path to the ''private'' key you just created (without a {{file|.pub}} suffix).  If the username to which Amanda should connect is different from the default, then you should also add
  client_username "otherusername"
If your server amandad path and client amandad path are different, you should also add
  amandad_path "/client/amandad/path"


* You mush append the /home/amandabackup/.ssh/id_rsa_amdump.pub file to the .ssh/authorized_keys (if unsure, check /etc/ssh/sshd_config for what your authorized_keys file is set to) file of all Amanda clients.
Append the '''public''' key you created earlier ({{file|id_rsa_amdump.pub}}, ''not'' {{file|id_rsa_amdump}}) file to {{file|~/.ssh/authorized_keys}} file on all Amanda clients.


* For security reasons, you must prepend the line with the following:
For a marginal increase in security, prepend the {{file|authorized_keys}} line with the following:
   from="<Amanda_server_fqdn_name>",no-port-forwarding,no-X11-forwarding,
   from="''amanda_server.your.domain.com''",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,command="''/absolute/path/to/amandad'' -auth=ssh amdump"
  no-agent-forwarding,command="<absolute path to amandad> -auth=ssh amdump"
This will limit that key to connect only from Amanda server and only be able to execute {{man|8|amandad}}.
This will limit that key to connect only from Amanda server and only be able to execute amandad.


* If your server username and client username are different, you must add the client_username option in dumptype definition for all DLEs in the client:
For client connections to the server, reverse the process -- put the public key (the same key or a new one -- your choice) on the clients, and the public key in the server's {{file|~/.ssh/authorized_keys}} file.  Prefix the {{file|authorized_keys}} line with:
  client_username "client_backup_username"
from="''amanda_client.your.domain.com''",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,command="''/absolute/path/to/amandad'' -auth=ssh amindexd amidxtaped"
You can omit the <tt>from=..</tt> option if you have too many clients to list, although this has obvious security implications.


* If your server amandad path and client amandad path are different, you must set the amandad_path option in all DLE for that hosts:
Set ''ssh_keys'' and any other necessary options in {{file|/etc/amanda/amanda_client.conf}}:
   amandad_path "client/amandad/path"
  auth "ssh"
  ssh_keys "/root/.ssh/id_rsa_amrecover"
  client_username "amanda"
   amandad_path "/server/amandad/path"


* Use the dumptype similar to the following:
==Host Keys==
  define dumptype nocomp-ssh {
Besides user keys, SSH uses host keys to uniquely identify each host, to prevent one host from impersonating another. One way to set up these host keys is to make a connection and tell SSH that you trust the identity:
  root-tar
  comment "ssh authorization and dumped with tar"
  auth "ssh"
  ssh_keys "/var/lib/amanda/.ssh/id_rsa_amdump"
  compress none
}
 
* Make sure Amanda Client in the known_hosts file by doing:
  $ ssh client1.zmanda.com
  $ ssh client1.zmanda.com
  The authenticity of host 'client1.zmanda.com (192.168.10.1)' can't be established.
  The authenticity of host 'client1.zmanda.com (192.168.10.1)' can't be established.
  RSA key fingerprint is 26:4e:df:a2:be:c8:cb:20:1c:68:8b:cc:c0:3b:8e:9d.
  RSA key fingerprint is 26:4e:df:a2:be:c8:cb:20:1c:68:8b:cc:c0:3b:8e:9d.
  Are you sure you want to continue connecting (yes/no)?yes
  Are you sure you want to continue connecting (yes/no)?yes
Since Amanda will not answer this question itself, you must manually make every connection (server to client and client to server) that you expect Amanda to make.  This is a drag, but you only have to do it once.


===Recovery process [[amrecover]]===
You must ssh to exactly the domain name(s) in your disklist entries. To SSH, <tt>foo</tt> is not the same as <tt>foo.fully.qualified.domain.name.example.com</tt>.


* Create a ssh key for root on all clients that can use [[amrecover]]. In this example, the key is put in the /root/.ssh/id_rsa_amrecover file:
The other option is to add
StrictHostKeyChecking no
to <tt>/etc/ssh/ssh_config</tt>.  This may cause a failure on the first connection, but will automatically add the key to the database and work subsequently.


Log in as root:
==Non-Standard SSH Port==
  # ssh-keygen -t rsa
If SSH is running on a port other than 22, you can add the port in the dumptype
  Enter file in which to save the key (/root/.ssh/id_rsa)? /root/.ssh/id_rsa_amrecover


* You must set the ssh_keys option in the ''/etc/amanda/amanda_client.conf'' file
   client-port 2222
   ssh_keys "/root/.ssh/id_rsa_amrecover"


* You mush append all client /home/root/.ssh/id_rsa_amrecover.pub file to the /home/amandabackup/.ssh/authorized_keys of the server.
or edit the ~amanda/.ssh/config file to specify the appropriate port. For example:


* For security reasons, you must prefix all lines with the following:
   Host somehost.example.com
from="aclient_fqdn_name",no-port-forwarding,no-X11-forwarding,
    Port 2222
   no-agent-forwarding,command="/path/to/amandad -auth=ssh amindexd amidxtaped"
This will limit every client key to connect from the client and only be able to execute amandad.


*Make sure the Amanda server is in ssh known_hosts file (Make sure to use FQDN)
==inetd/xinetd==
#ssh server.zmanda.com
An inetd or xinetd entry is not needed for ssh auth.
The authenticity of host 'server.zmanda.com (192.168.10.1)' can't be established.
RSA key fingerprint is 26:4e:df:a2:be:c8:cb:20:1c:68:8b:cc:c0:3b:8e:9d.
Are you sure you want to continue connecting (yes/no)?yes

Latest revision as of 00:06, 19 February 2017

This article is a part of the How Tos collection.

SSH provides transport encryption and authentication. To set up an SSH authentication session, Amanda will run the equivalent of:

/path/to/ssh -l <CLIENT_LOGIN> client.zmanda.com $libexecdir/amandad

to start the backup process.

To do so, you need to set up ssh keys either by storing the passphrase in cleartext, using ssh-agent, or using no passphrase at all. All of these options have security implications which should be carefully considered before adoption. This article describes setting up SSH keys with no passphrase. It should be fairly easy to adapt it to the other options.

When you use a public key on the client to do data encryption (see How To:Set up data encryption), you can lock away the private key in a secure place. Both, transport and storage will be encrypted with such a setup. See encryption for an overview of encryption options.

Setup

First, set up passwordless login between the amanda server and all clients. This requires two things: distributing SSH keys and setting up host keys. This page details the SSH configuration; the Amanda configuration is described authoritatively in amanda-auth(7).

SSH Keys

Create an ssh key for the Amanda server, and make sure you just hit enter when asked for a key passphrase. In this example, the key is put in the id_rsa_amdump file (Run this as the backup user - amandabackup or amanda):

 $ ssh-keygen -t rsa -C "SSH Key for Amanda Backups"
 Enter file in which to save the key (/home/amandabackup/.ssh/id_rsa)? /home/amandabackup/.ssh/id_rsa_amdump

Enable SSH authentication and set the ssh_keys option in all DLEs for that host by adding the following to the DLE itself or to the corresponding dumptype in amanda.conf:

 auth "ssh"
 ssh_keys "/home/amandabackup/.ssh/id_rsa_amdump"

Note that ssh_keys is the path to the private key you just created (without a .pub suffix). If the username to which Amanda should connect is different from the default, then you should also add

 client_username "otherusername"

If your server amandad path and client amandad path are different, you should also add

 amandad_path "/client/amandad/path"

Append the public key you created earlier (id_rsa_amdump.pub, not id_rsa_amdump) file to ~/.ssh/authorized_keys file on all Amanda clients.

For a marginal increase in security, prepend the authorized_keys line with the following:

 from="amanda_server.your.domain.com",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,command="/absolute/path/to/amandad -auth=ssh amdump"

This will limit that key to connect only from Amanda server and only be able to execute amandad(8).

For client connections to the server, reverse the process -- put the public key (the same key or a new one -- your choice) on the clients, and the public key in the server's ~/.ssh/authorized_keys file. Prefix the authorized_keys line with:

from="amanda_client.your.domain.com",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,command="/absolute/path/to/amandad -auth=ssh amindexd amidxtaped"

You can omit the from=.. option if you have too many clients to list, although this has obvious security implications.

Set ssh_keys and any other necessary options in /etc/amanda/amanda_client.conf:

 auth "ssh"
 ssh_keys "/root/.ssh/id_rsa_amrecover"
 client_username "amanda"
 amandad_path "/server/amandad/path"

Host Keys

Besides user keys, SSH uses host keys to uniquely identify each host, to prevent one host from impersonating another. One way to set up these host keys is to make a connection and tell SSH that you trust the identity:

$ ssh client1.zmanda.com
The authenticity of host 'client1.zmanda.com (192.168.10.1)' can't be established.
RSA key fingerprint is 26:4e:df:a2:be:c8:cb:20:1c:68:8b:cc:c0:3b:8e:9d.
Are you sure you want to continue connecting (yes/no)?yes

Since Amanda will not answer this question itself, you must manually make every connection (server to client and client to server) that you expect Amanda to make. This is a drag, but you only have to do it once.

You must ssh to exactly the domain name(s) in your disklist entries. To SSH, foo is not the same as foo.fully.qualified.domain.name.example.com.

The other option is to add

StrictHostKeyChecking no

to /etc/ssh/ssh_config. This may cause a failure on the first connection, but will automatically add the key to the database and work subsequently.

Non-Standard SSH Port

If SSH is running on a port other than 22, you can add the port in the dumptype

 client-port 2222

or edit the ~amanda/.ssh/config file to specify the appropriate port. For example:

 Host somehost.example.com
   Port 2222

inetd/xinetd

An inetd or xinetd entry is not needed for ssh auth.