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
This commit is contained in:
tb@openbsd.org 2019-01-21 22:50:42 +00:00 committed by Damien Miller
parent c882d74652
commit 622dedf1a8
4 changed files with 43 additions and 14 deletions

17
scp.1
View File

@ -8,9 +8,9 @@
.\" .\"
.\" Created: Sun May 7 00:14:37 1995 ylo .\" 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 .Dt SCP 1
.Os .Os
.Sh NAME .Sh NAME
@ -106,6 +106,19 @@ Selects the file from which the identity (private key) for public key
authentication is read. authentication is read.
This option is directly passed to This option is directly passed to
.Xr ssh 1 . .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 .It Fl l Ar limit
Limits the used bandwidth, specified in Kbit/s. Limits the used bandwidth, specified in Kbit/s.
.It Fl o Ar ssh_option .It Fl o Ar ssh_option

8
scp.c
View File

@ -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 * scp - secure remote copy. This is basically patched BSD rcp which
* uses ssh to do the data transfer (instead of using rcmd). * uses ssh to do the data transfer (instead of using rcmd).
@ -424,7 +424,7 @@ main(int argc, char **argv)
addargs(&args, "-oRequestTTY=no"); addargs(&args, "-oRequestTTY=no");
fflag = tflag = 0; 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) { switch (ch) {
/* User-visible flags. */ /* User-visible flags. */
case '1': case '1':
@ -446,6 +446,7 @@ main(int argc, char **argv)
case 'c': case 'c':
case 'i': case 'i':
case 'F': case 'F':
case 'J':
addargs(&remote_remote_args, "-%c", ch); addargs(&remote_remote_args, "-%c", ch);
addargs(&remote_remote_args, "%s", optarg); addargs(&remote_remote_args, "%s", optarg);
addargs(&args, "-%c", ch); addargs(&args, "-%c", ch);
@ -1319,7 +1320,8 @@ usage(void)
{ {
(void) fprintf(stderr, (void) fprintf(stderr,
"usage: scp [-346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]\n" "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); exit(1);
} }

18
sftp.1
View File

@ -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. .\" 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 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd $Mdocdate: January 16 2019 $ .Dd $Mdocdate: January 21 2019 $
.Dt SFTP 1 .Dt SFTP 1
.Os .Os
.Sh NAME .Sh NAME
@ -37,6 +37,7 @@
.Op Fl D Ar sftp_server_path .Op Fl D Ar sftp_server_path
.Op Fl F Ar ssh_config .Op Fl F Ar ssh_config
.Op Fl i Ar identity_file .Op Fl i Ar identity_file
.Op Fl J Ar destination
.Op Fl l Ar limit .Op Fl l Ar limit
.Op Fl o Ar ssh_option .Op Fl o Ar ssh_option
.Op Fl P Ar port .Op Fl P Ar port
@ -181,6 +182,19 @@ Selects the file from which the identity (private key) for public key
authentication is read. authentication is read.
This option is directly passed to This option is directly passed to
.Xr ssh 1 . .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 .It Fl l Ar limit
Limits the used bandwidth, specified in Kbit/s. Limits the used bandwidth, specified in Kbit/s.
.It Fl o Ar ssh_option .It Fl o Ar ssh_option

14
sftp.c
View File

@ -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 <djm@openbsd.org> * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
* *
@ -2362,11 +2362,10 @@ usage(void)
fprintf(stderr, fprintf(stderr,
"usage: %s [-46aCfpqrv] [-B buffer_size] [-b batchfile] [-c cipher]\n" "usage: %s [-46aCfpqrv] [-B buffer_size] [-b batchfile] [-c cipher]\n"
" [-D sftp_server_path] [-F ssh_config] " " [-D sftp_server_path] [-F ssh_config] [-i identity_file]\n"
"[-i identity_file] [-l limit]\n" " [-J destination] [-l limit] [-o ssh_option] [-P port]\n"
" [-o ssh_option] [-P port] [-R num_requests] " " [-R num_requests] [-S program] [-s subsystem | sftp_server]\n"
"[-S program]\n" " destination\n",
" [-s subsystem | sftp_server] destination\n",
__progname); __progname);
exit(1); exit(1);
} }
@ -2409,7 +2408,7 @@ main(int argc, char **argv)
infile = stdin; infile = stdin;
while ((ch = getopt(argc, argv, 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) { switch (ch) {
/* Passed through to ssh(1) */ /* Passed through to ssh(1) */
case '4': case '4':
@ -2419,6 +2418,7 @@ main(int argc, char **argv)
break; break;
/* Passed through to ssh(1) with argument */ /* Passed through to ssh(1) with argument */
case 'F': case 'F':
case 'J':
case 'c': case 'c':
case 'i': case 'i':
case 'o': case 'o':