Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rsnapshot misinterprete ssh_args (Unexpected remote arg) #258

Open
Inkvisitor opened this issue May 28, 2020 · 7 comments
Open

rsnapshot misinterprete ssh_args (Unexpected remote arg) #258

Inkvisitor opened this issue May 28, 2020 · 7 comments

Comments

@Inkvisitor
Copy link

Inkvisitor commented May 28, 2020

Hello,

The situation is that rnapshot forms ssh_args for rsync that way so they became as source instead of arguments or something like that. Examples and detailed explanation below:

version: rsnapshot-1.4.3-1

Here is rsnapshot config:

################################################################################
config_version	1.2
snapshot_root	/backup/rsnapshot/remote.server.tld/
cmd_cp		/usr/bin/cp
cmd_rm		/usr/bin/rm
cmd_rsync	/usr/bin/rsync
cmd_ssh	/usr/bin/ssh
cmd_logger	/usr/bin/logger
cmd_du		/usr/bin/du
cmd_rsnapshot_diff	/bin/rsnapshot-diff
retain	monthly	2
verbose		2
loglevel	3
lockfile	/var/run/rsnapshot_remote.server.tld.pid
logfile		/var/log/rsnapshot/rsnapshot_remote.server.tld.log
rsync_long_args	--bwlimit=30000
ssh_args	-p 22 -i /etc/rsnapshot.d/id_rsa

backup	root@123.456.789.123:/home/backup/		remote.server.tld/
backup	root@123.456.789.123:/etc/			remote.server.tld/
backup	root@123.456.789.123:/var/www/		remote.server.tld/
################################################################################

here is part of result of rsnapshot -t -c /etc/rsnapshot.d/rsnapshot_remote.server.tld monthly command (just to be briefer):

/usr/bin/rsync -a --bwlimit=30000 --rsh=/usr/bin/ssh -p 22 -i \
    /etc/rsnapshot.d/id_rsa root@123.456.789.123:/var/www/ \
    /backup/rsnapshot/remote.server.tld/monthly.0/remote.server.tld/ 

If you would run the rsync command directly as it is (from console), it would return error:

# /usr/bin/rsync -a --bwlimit=30000 --rsh=/usr/bin/ssh -p 22 -i \
>     /etc/rsnapshot.d/id_rsa root@123.456.789.123:/var/www/ \
>     /backup/rsnapshot/remote.server.tld/test/ 2>&1
Unexpected remote arg: root@123.456.789.123:/var/www/
rsync error: syntax or usage error (code 1) at main.c(1344) [sender=3.1.2]

But, if I put the --rsh arguments for the rsync command between quotes, it works as expected:

/usr/bin/rsync -a --rsh="/usr/bin/ssh -p 22 -i /etc/rsnapshot.d/id_rsa" \
    root@123.456.789.123:/var/www/ \
    /backup/rsnapshot/remote.server.tld/test/ 

So here is the question: is it possible to make rsnapshot acting the similar way?

@StefanMoch
Copy link
Contributor

The easiest and cleanest way to do this, would be:

  • leave ssh_args out
  • change root@123.456.789.123 to remote.server.tld in your rsnapshot configuration
  • configure ssh to use your key in /root/.ssh/config:
Host remote.server.tld
	IdentityFile /etc/rsnapshot.d/id_rsa
	# Port 22 # only needed if you changed it somewhere else
	# User root # ssh uses the local user name for the remote login if not changed, so probably not needed
	# HostName 123.456.789.123 # only needed if the name resolution (DNS or hosts) does not work, or remote.server.tld is an alias just for rsnapshot, see below.

If you normally use another IdentityFile and this would disturb your other logins to this machine, you can use another name as an alias for this machine in your source argument in rsnapshot.conf and on the Host line in .ssh/config, but then you will need the HostName line either IP address or name.

@Inkvisitor
Copy link
Author

The easiest and cleanest way to do this, would be:

* leave `ssh_args` out

* change `root@123.456.789.123` to `remote.server.tld` in your rsnapshot configuration

* configure ssh to use your key in `/root/.ssh/config`:
Host remote.server.tld
	IdentityFile /etc/rsnapshot.d/id_rsa
	# Port 22 # only needed if you changed it somewhere else
	# User root # ssh uses the local user name for the remote login if not changed, so probably not needed
	# HostName 123.456.789.123 # only needed if the name resolution (DNS or hosts) does not work, or remote.server.tld is an alias just for rsnapshot, see below.

If you normally use another IdentityFile and this would disturb your other logins to this machine, you can use another name as an alias for this machine in your source argument in rsnapshot.conf and on the Host line in .ssh/config, but then you will need the HostName line either IP address or name.

Thank you very much! This workaround works for our case!

@djk20
Copy link
Member

djk20 commented Jun 14, 2020 via email

@pr0fsmith
Copy link

I'm having the same issue but I don't really understand the solution. Can you break it down in layman's terms or tell me what I should google to figure this out? I'm lost at this line "hange root@123.456.789.123 to remote.server.tld in your rsnapshot configuration"

@backit
Copy link

backit commented Mar 30, 2022

I'm having the same issue but I don't really understand the solution. Can you break it down in layman's terms or tell me what I should google to figure this out? I'm lost at this line "hange root@123.456.789.123 to remote.server.tld in your rsnapshot configuration"

This is to use a ssh configuration to access the server instead passing args to ssh. In your $HOME/.ssh/config file set configurations parameter to connect to server. For example you want to connect to server 1.2.3.4 as root, then set:

Host myserver
   hostname 1.2.3.4
   user root

you can also configure a port (if different from 22), or identityfile if different from that used by you user.

then you call:
ssh myserver
and you connect to 1.2.3.4 as root

@pr0fsmith
Copy link

pr0fsmith commented Mar 30, 2022 via email

@pr0fsmith
Copy link

pr0fsmith commented Apr 10, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants