[Bug] Support ssh sources without a username [sf#16]
bebehei opened this issue · comments
Reported by hashproduct on 2009-11-21 14:28 UTC
Rsnapshot currently requires that ssh sources specify a username (USER@HOST:PATH), and rsync has no such requirement. The rsnapshot requirement should be relaxed for users who want to let ssh pick up the proper username from its configuration. See https://sourceforge.net/mailarchive/forum.php?thread\_name=4AD8423A.4020002%40vevida.nl&forum\_name=rsnapshot-discuss .
Commented by hashproduct on 2010-03-18 03:03 UTC
Proposed patch to make the username optional
Attached filessh-optional-username.patch:
Make the username optional for ssh backup points.
https://sourceforge.net/tracker/?func=detail&aid=2901768&group_id=88546&atid=587076
---
rsnapshot-program.pl | 16 ++++++++++++++--
rsnapshot.1 | 11 ++++++++++-
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/rsnapshot-program.pl b/rsnapshot-program.pl
index 03f2fdb..441a95a 100755
--- a/rsnapshot-program.pl
+++ b/rsnapshot-program.pl
@@ -2673,8 +2673,11 @@ sub is_ssh_path {
if ($path =~ m/^\s/) { return (undef); }
if ($path =~ m/\s$/) { return (undef); }
- # must have user@host:[~]/path syntax for ssh
- if ($path =~ m/^.*?\@.*?:~?\/.*$/) { return (1); }
+ # don't match paths that look like URIs (rsync://, etc.)
+ if ($path =~ m,://,) { return (undef); }
+
+ # must have [user@]host:[~]/path syntax for ssh
+ if ($path =~ m/^(.*?\@)?.*?:~?\/.*$/) { return (1); }
return (0);
}
@@ -6606,6 +6609,15 @@ using rsync over ssh
=back
+B<backup example.com:/etc/ example.com/>
+
+=over 4
+
+Same thing but let ssh choose the remote username (as specified in
+~/.ssh/config, otherwise the same as the local username)
+
+=back
+
B<backup root@example.com:/usr/local/ example.com/>
=over 4
diff --git a/rsnapshot.1 b/rsnapshot.1
index 2ca629b..fd2288c 100644
--- a/rsnapshot.1
+++ b/rsnapshot.1
@@ -132,7 +132,7 @@
.\" ========================================================================
.\"
.IX Title "RSNAPSHOT-PROGRAM 1"
-.TH RSNAPSHOT-PROGRAM 1 "2009-01-21" "perl v5.10.0" "User Contributed Perl Documentation"
+.TH RSNAPSHOT-PROGRAM 1 "2010-03-17" "perl v5.10.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
@@ -626,6 +626,15 @@ using rsync over ssh
.RE
.RS 4
.Sp
+\&\fBbackup example.com:/etc/ example.com/\fR
+.Sp
+.RS 4
+Same thing but let ssh choose the remote username (as specified in
+~/.ssh/config, otherwise the same as the local username)
+.RE
+.RE
+.RS 4
+.Sp
\&\fBbackup root@example.com:/usr/local/ example.com/\fR
.Sp
.RS 4
--
1.7.0.rc2.19.g05776
Commented by hashproduct on 2010-07-23 10:01 UTC
I committed the patch.
Updated by hashproduct on 2010-07-23 10:01 UTC
- status: open --> closed-fixed