ssh-proxy: add scp and rsync support
ssh-generator and ssh-proxy are great features, it is very handy to be
able to do:
ssh vsock/1
But, because of the '/' used as a separator, scp and rsync don't
interpret 'vsock/<CID>' as a hostname, e.g.
$ scp /etc/machine-id vsock/2222:.
cp: cannot create regular file 'vsock/2222:.': No such file or directory
$ rsync /etc/machine-id vsock/2222:.
rsync: [Receiver] change_dir#3 "(...)/vsock" failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(829) [Receiver=3.4.1]
An alternative is to use ',' as separator, e.g.
$ scp /etc/machine-id vsock,2222:.
This is what is being suggested here. The names with '/' are kept not to
break anything here.
Others are possible: '%', '=', '#', '@', ':', etc. As mentioned in
commit 0abd510f7f ("ssh-proxy: add ssh ProxyCommand tool that can
connect to AF_UNIX + AF_VSOCK sockets"), it is better to avoid ':' as it
is already taken by SSH itself when doing sftp, and "@" is already taken
for separating the user name. '#' will cause some issues with some
shells like ZSH when quotes are not used.
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
ae04218383
commit
defd5060d6
@@ -175,6 +175,15 @@ static int process_machine(const char *machine, const char *port) {
|
||||
return process_vsock_cid(cid, port);
|
||||
}
|
||||
|
||||
static char *startswith_sep(const char *s, const char *prefix) {
|
||||
const char *p = startswith(s, prefix);
|
||||
|
||||
if (p && IN_SET(*p, '/', ','))
|
||||
return (char*) p + 1;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int run(int argc, char* argv[]) {
|
||||
|
||||
log_setup();
|
||||
@@ -184,19 +193,19 @@ static int run(int argc, char* argv[]) {
|
||||
|
||||
const char *host = argv[1], *port = argv[2];
|
||||
|
||||
const char *p = startswith(host, "vsock/");
|
||||
const char *p = startswith_sep(host, "vsock");
|
||||
if (p)
|
||||
return process_vsock_string(p, port);
|
||||
|
||||
p = startswith(host, "unix/");
|
||||
p = startswith_sep(host, "unix");
|
||||
if (p)
|
||||
return process_unix(p);
|
||||
|
||||
p = startswith(host, "vsock-mux/");
|
||||
p = startswith_sep(host, "vsock-mux");
|
||||
if (p)
|
||||
return process_vsock_mux(p, port);
|
||||
|
||||
p = startswith(host, "machine/");
|
||||
p = startswith_sep(host, "machine");
|
||||
if (p)
|
||||
return process_machine(p, port);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user