From 622dedf1a884f2927a9121e672bd9955e12ba108 Mon Sep 17 00:00:00 2001 From: "tb@openbsd.org" Date: Mon, 21 Jan 2019 22:50:42 +0000 Subject: [PATCH] upstream: Add a -J option as a shortcut for -o Proxyjump= to scp(1) and sftp(1) to match ssh(1)'s interface. ok djm OpenBSD-Commit-ID: a75bc2d5f329caa7229a7e9fe346c4f41c2663fc --- scp.1 | 17 +++++++++++++++-- scp.c | 8 +++++--- sftp.1 | 18 ++++++++++++++++-- sftp.c | 14 +++++++------- 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/scp.1 b/scp.1 index 0e5cc1b2d..9fb6c23cb 100644 --- a/scp.1 +++ b/scp.1 @@ -8,9 +8,9 @@ .\" .\" Created: Sun May 7 00:14:37 1995 ylo .\" -.\" $OpenBSD: scp.1,v 1.81 2018/09/20 06:58:48 jmc Exp $ +.\" $OpenBSD: scp.1,v 1.82 2019/01/21 22:50:42 tb Exp $ .\" -.Dd $Mdocdate: September 20 2018 $ +.Dd $Mdocdate: January 21 2019 $ .Dt SCP 1 .Os .Sh NAME @@ -106,6 +106,19 @@ Selects the file from which the identity (private key) for public key authentication is read. This option is directly passed to .Xr ssh 1 . +.It Fl J Ar destination +Connect to the target host by first making a +.Nm +connection to the jump host described by +.Ar destination +and then establishing a TCP forwarding to the ultimate destination from +there. +Multiple jump hops may be specified separated by comma characters. +This is a shortcut to specify a +.Cm ProxyJump +configuration directive. +This option is directly passed to +.Xr ssh 1 . .It Fl l Ar limit Limits the used bandwidth, specified in Kbit/s. .It Fl o Ar ssh_option diff --git a/scp.c b/scp.c index eb17c3416..ae51137ee 100644 --- a/scp.c +++ b/scp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scp.c,v 1.198 2018/11/16 03:03:10 djm Exp $ */ +/* $OpenBSD: scp.c,v 1.199 2019/01/21 22:50:42 tb Exp $ */ /* * scp - secure remote copy. This is basically patched BSD rcp which * uses ssh to do the data transfer (instead of using rcmd). @@ -424,7 +424,7 @@ main(int argc, char **argv) addargs(&args, "-oRequestTTY=no"); fflag = tflag = 0; - while ((ch = getopt(argc, argv, "dfl:prtvBCc:i:P:q12346S:o:F:")) != -1) + while ((ch = getopt(argc, argv, "dfl:prtvBCc:i:P:q12346S:o:F:J:")) != -1) switch (ch) { /* User-visible flags. */ case '1': @@ -446,6 +446,7 @@ main(int argc, char **argv) case 'c': case 'i': case 'F': + case 'J': addargs(&remote_remote_args, "-%c", ch); addargs(&remote_remote_args, "%s", optarg); addargs(&args, "-%c", ch); @@ -1319,7 +1320,8 @@ usage(void) { (void) fprintf(stderr, "usage: scp [-346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]\n" - " [-l limit] [-o ssh_option] [-P port] [-S program] source ... target\n"); + " [-J destination] [-l limit] [-o ssh_option] [-P port]\n" + " [-S program] source ... target\n"); exit(1); } diff --git a/sftp.1 b/sftp.1 index 722a34419..ce12fc537 100644 --- a/sftp.1 +++ b/sftp.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sftp.1,v 1.123 2019/01/16 23:23:45 djm Exp $ +.\" $OpenBSD: sftp.1,v 1.124 2019/01/21 22:50:42 tb Exp $ .\" .\" Copyright (c) 2001 Damien Miller. All rights reserved. .\" @@ -22,7 +22,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: January 16 2019 $ +.Dd $Mdocdate: January 21 2019 $ .Dt SFTP 1 .Os .Sh NAME @@ -37,6 +37,7 @@ .Op Fl D Ar sftp_server_path .Op Fl F Ar ssh_config .Op Fl i Ar identity_file +.Op Fl J Ar destination .Op Fl l Ar limit .Op Fl o Ar ssh_option .Op Fl P Ar port @@ -181,6 +182,19 @@ Selects the file from which the identity (private key) for public key authentication is read. This option is directly passed to .Xr ssh 1 . +.It Fl J Ar destination +Connect to the target host by first making a +.Nm +connection to the jump host described by +.Ar destination +and then establishing a TCP forwarding to the ultimate destination from +there. +Multiple jump hops may be specified separated by comma characters. +This is a shortcut to specify a +.Cm ProxyJump +configuration directive. +This option is directly passed to +.Xr ssh 1 . .It Fl l Ar limit Limits the used bandwidth, specified in Kbit/s. .It Fl o Ar ssh_option diff --git a/sftp.c b/sftp.c index 0f3f89d33..44aa19d96 100644 --- a/sftp.c +++ b/sftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp.c,v 1.189 2019/01/16 23:23:45 djm Exp $ */ +/* $OpenBSD: sftp.c,v 1.190 2019/01/21 22:50:42 tb Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller * @@ -2362,11 +2362,10 @@ usage(void) fprintf(stderr, "usage: %s [-46aCfpqrv] [-B buffer_size] [-b batchfile] [-c cipher]\n" - " [-D sftp_server_path] [-F ssh_config] " - "[-i identity_file] [-l limit]\n" - " [-o ssh_option] [-P port] [-R num_requests] " - "[-S program]\n" - " [-s subsystem | sftp_server] destination\n", + " [-D sftp_server_path] [-F ssh_config] [-i identity_file]\n" + " [-J destination] [-l limit] [-o ssh_option] [-P port]\n" + " [-R num_requests] [-S program] [-s subsystem | sftp_server]\n" + " destination\n", __progname); exit(1); } @@ -2409,7 +2408,7 @@ main(int argc, char **argv) infile = stdin; while ((ch = getopt(argc, argv, - "1246afhpqrvCc:D:i:l:o:s:S:b:B:F:P:R:")) != -1) { + "1246afhpqrvCc:D:i:l:o:s:S:b:B:F:J:P:R:")) != -1) { switch (ch) { /* Passed through to ssh(1) */ case '4': @@ -2419,6 +2418,7 @@ main(int argc, char **argv) break; /* Passed through to ssh(1) with argument */ case 'F': + case 'J': case 'c': case 'i': case 'o':