jborg / attic

Deduplicating backup program
Other
1.11k stars 104 forks source link

Support custom ssh binary / ssh options? #99

Open mappu opened 10 years ago

mappu commented 10 years ago

Hi! I'm looking to supply a custom identityfile to ssh. It looks like the ssh command is hardcoded in attic/remote.py and at the moment it's not possible to add custom commandline to the invocation of the ssh binary (correct me if i'm wrong...)

Would it be possible to add some e.g. --ssh-command option, so that i can write e.g. --ssh-command="/opt/my/custom/built/ssh -i path/to/id_rsa -o foo=bar" ?

I guess it would be currently possible to workaround by hacking $PATH and pointing ssh to a local wrapper script... but surely custom identity files and other SSH options are common enough to warrant having this in the core (e.g. rdiff-backup has --remote-schema)

jure1 commented 10 years ago

You could put it into your ~/.ssh/config file and add these lines Host BackupServer IdentityFile /xxx/yyy ...

mappu commented 10 years ago

Yes, that works for changing the port and ssh options, and i decided to do that in the interim.

However i feel it's inappropriate to use a global solution to a local problem, it doesn't keep all backup-relevant configuration together, and it's less flexible than allowing the command to be changed.

@amon-ra 's fork with windows support added this feature already https://github.com/amon-ra/attic/commit/ab590c0d1209caeaedd49fa76cf934f4c8fee740

jborg commented 10 years ago

You can use .ssh/config to set server specific settings as well like this:

Host mybackupconfiguration
Hostname my-backup-server-hostname
IdentityFile /xxx/yyy

Then specify mybacupconfiguration instead of the server hostname when invoking attic:

$ attic create mybacupconfiguration::archivename ...
iskunk commented 10 years ago

I would suggest an environment variable ATTIC_RSH, similar to CVS_RSH and RSYNC_RSH. Not only would this let you specify custom options to SSH, you can specify a custom SSH binary, or even a different program [with compatible syntax] that isn't SSH at all.

If there is also a command-line option, it should be called --rsh=FOO or --rsh-command=FOO, as SSH is a specific instance of the more general class of remote-shell programs. (For what it's worth, rsync uses --rsh=FOO.)

cjhardekopf commented 10 years ago

I would also find it useful to be able to specify an ssh command line wither with an environment variable or on the command line.

shyblower commented 9 years ago

Unfortunately it is not possible ("You may only use this configuration option from the command line") to put the "NoneSwitch" option into ssh config. This option is available with the HPN (https://www.psc.edu/index.php/hpn-ssh) patched ssh package. Together with "NoneEnabled" it disables encryption during data transfer which helps to speed up backups over ssh in environments where transport encryption is not necessary (e.g. home LAN) but mounting a writable backup destination is not an option (I don't want my backupped data getting accidentally deleted by the client because someone does an "rm -rf /" or something similar). So at least for this use case it would be good to be able to set custom ssh options with attic.