git: fb5aabcb990b - main - scp: switch to using the SFTP protocol by default
Date: Fri, 15 Apr 2022 14:47:34 UTC
The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=fb5aabcb990bdc9a2359f56b714795da0d79416d commit fb5aabcb990bdc9a2359f56b714795da0d79416d Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2022-04-14 00:50:17 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2022-04-15 14:47:28 +0000 scp: switch to using the SFTP protocol by default From upstream release notes https://www.openssh.com/txt/release-9.0 This release switches scp(1) from using the legacy scp/rcp protocol to using the SFTP protocol by default. Legacy scp/rcp performs wildcard expansion of remote filenames (e.g. "scp host:* .") through the remote shell. This has the side effect of requiring double quoting of shell meta-characters in file names included on scp(1) command-lines, otherwise they could be interpreted as shell commands on the remote side. This creates one area of potential incompatibility: scp(1) when using the SFTP protocol no longer requires this finicky and brittle quoting, and attempts to use it may cause transfers to fail. We consider the removal of the need for double-quoting shell characters in file names to be a benefit and do not intend to introduce bug-compatibility for legacy scp/rcp in scp(1) when using the SFTP protocol. Another area of potential incompatibility relates to the use of remote paths relative to other user's home directories, for example - "scp host:~user/file /tmp". The SFTP protocol has no native way to expand a ~user path. However, sftp-server(8) in OpenSSH 8.7 and later support a protocol extension "expand-path@openssh.com" to support this. In case of incompatibility, the scp(1) client may be instructed to use the legacy scp/rcp using the -O flag. Relnotes: Yes Sponsored by: The FreeBSD Foundation --- crypto/openssh/scp.1 | 24 ++++++++++++++---------- crypto/openssh/scp.c | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/crypto/openssh/scp.1 b/crypto/openssh/scp.1 index c433f7168e07..f39066d4448d 100644 --- a/crypto/openssh/scp.1 +++ b/crypto/openssh/scp.1 @@ -8,9 +8,9 @@ .\" .\" Created: Sun May 7 00:14:37 1995 ylo .\" -.\" $OpenBSD: scp.1,v 1.107 2022/02/10 04:12:38 djm Exp $ +.\" $OpenBSD: scp.1,v 1.108 2022/02/23 21:21:16 djm Exp $ .\" -.Dd $Mdocdate: February 10 2022 $ +.Dd $Mdocdate: February 23 2022 $ .Dt SCP 1 .Os .Sh NAME @@ -76,7 +76,9 @@ The options are as follows: Copies between two remote hosts are transferred through the local host. Without this option the data is copied directly between the two remote hosts. -Note that, when using the original SCP protocol (the default), this option +Note that, when using the legacy SCP protocol (via the +.Fl O +flag), this option selects batch mode for the second host as .Nm cannot ask for passwords or passphrases for both hosts. @@ -109,7 +111,7 @@ This option is directly passed to .Xr ssh 1 . .It Fl D Ar sftp_server_path When using the SFTP protocol support via -.Fl s , +.Fl M , connect directly to a local SFTP server program rather than a remote one via .Xr ssh 1 . @@ -141,13 +143,12 @@ This option is directly passed to .It Fl l Ar limit Limits the used bandwidth, specified in Kbit/s. .It Fl O -Use the original SCP protocol for file transfers instead of the SFTP protocol. +Use the legacy SCP protocol for file transfers instead of the SFTP protocol. Forcing the use of the SCP protocol may be necessary for servers that do not implement SFTP, for backwards-compatibility for particular filename wildcard patterns and for expanding paths with a .Sq ~ prefix for older SFTP servers. -This mode is the default. .It Fl o Ar ssh_option Can be used to pass options to .Nm ssh @@ -257,8 +258,6 @@ to use for the encrypted connection. The program must understand .Xr ssh 1 options. -.It Fl s -Use the SFTP protocol for transfers rather than the original scp protocol. .It Fl T Disable strict filename checking. By default when copying files from a remote host to a local directory @@ -295,12 +294,17 @@ debugging connection, authentication, and configuration problems. is based on the rcp program in .Bx source code from the Regents of the University of California. +.Pp +Since OpenSSH 9.0, +.Nm +has use the SFTP protocol for transfers by default. .Sh AUTHORS .An Timo Rinne Aq Mt tri@iki.fi .An Tatu Ylonen Aq Mt ylo@cs.hut.fi .Sh CAVEATS -The original SCP protocol (used by default) requires execution of the -remote user's shell to perform +The legacy SCP protocol (selected by the +.Fl O +flag) requires execution of the remote user's shell to perform .Xr glob 3 pattern matching. This requires careful quoting of any characters that have special meaning to diff --git a/crypto/openssh/scp.c b/crypto/openssh/scp.c index 7a3851c5fdd1..c36d66aa5941 100644 --- a/crypto/openssh/scp.c +++ b/crypto/openssh/scp.c @@ -449,7 +449,7 @@ main(int argc, char **argv) const char *errstr; extern char *optarg; extern int optind; - enum scp_mode_e mode = MODE_SCP; + enum scp_mode_e mode = MODE_SFTP; char *sftp_direct = NULL; /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */