summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2009-08-12 00:13:01 +0000
committerDamien Miller <djm@cvs.openbsd.org>2009-08-12 00:13:01 +0000
commit45d324f58707740248458c202443168dc976b2ab (patch)
treeea65a9256309bc7d25f0920aed5a8b49b0b5b5b2
parent6ea7e45057f5c520cd5827257984c1ddd91a23e8 (diff)
support most of scp(1)'s commandline arguments in sftp(1), as a first
step towards making sftp(1) a drop-in replacement for scp(1). One conflicting option (-P) has not been changed, pending further discussion. Patch from carlosvsilvapt@gmail.com as part of his work in the Google Summer of Code
-rw-r--r--usr.bin/ssh/sftp.131
-rw-r--r--usr.bin/ssh/sftp.c57
2 files changed, 64 insertions, 24 deletions
diff --git a/usr.bin/ssh/sftp.1 b/usr.bin/ssh/sftp.1
index 37ccb3a38ba..d7df8bbeebb 100644
--- a/usr.bin/ssh/sftp.1
+++ b/usr.bin/ssh/sftp.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sftp.1,v 1.69 2008/12/09 15:35:00 sobrado Exp $
+.\" $OpenBSD: sftp.1,v 1.70 2009/08/12 00:13:00 djm 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: December 9 2008 $
+.Dd $Mdocdate: August 12 2009 $
.Dt SFTP 1
.Os
.Sh NAME
@@ -31,10 +31,12 @@
.Sh SYNOPSIS
.Nm sftp
.Bk -words
-.Op Fl 1Cv
+.Op Fl 1246Cqv
.Op Fl B Ar buffer_size
.Op Fl b Ar batchfile
+.Op Fl c Ar cipher
.Op Fl F Ar ssh_config
+.Op Fl i Ar identity_path
.Op Fl o Ar ssh_option
.Op Fl P Ar sftp_server_path
.Op Fl R Ar num_requests
@@ -87,6 +89,16 @@ The options are as follows:
.Bl -tag -width Ds
.It Fl 1
Specify the use of protocol version 1.
+.It Fl 2
+Specify the use of protocol version 2.
+.It Fl 4
+Forces
+.Nm
+to use IPv4 addresses only.
+.It Fl 6
+Forces
+.Nm
+to use IPv6 addresses only.
.It Fl B Ar buffer_size
Specify the size of the buffer that
.Nm
@@ -120,6 +132,10 @@ prefixing the command with a
.Sq \-
character (for example,
.Ic -rm /tmp/blah* ) .
+.It Fl c Ar cipher
+Selects the cipher to use for encrypting the data transfers.
+This option is directly passed to
+.Xr ssh 1 .
.It Fl C
Enables compression (via ssh's
.Fl C
@@ -130,6 +146,11 @@ per-user configuration file for
.Xr ssh 1 .
This option is directly passed to
.Xr ssh 1 .
+.It Fl i Ar identity_file
+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 o Ar ssh_option
Can be used to pass options to
.Nm ssh
@@ -199,6 +220,10 @@ Connect directly to a local sftp server
(rather than via
.Xr ssh 1 ) .
This option may be useful in debugging the client and server.
+.It Fl q
+Quiet mode: disables the progress meter as well as warning and
+diagnostic messages from
+.Xr ssh 1 .
.It Fl R Ar num_requests
Specify how many requests may be outstanding at any one time.
Increasing this may slightly improve file transfer speed
diff --git a/usr.bin/ssh/sftp.c b/usr.bin/ssh/sftp.c
index 411da1e5185..09d3a25c8dc 100644
--- a/usr.bin/ssh/sftp.c
+++ b/usr.bin/ssh/sftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp.c,v 1.107 2009/02/02 11:15:14 dtucker Exp $ */
+/* $OpenBSD: sftp.c,v 1.108 2009/08/12 00:13:00 djm Exp $ */
/*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
*
@@ -1622,12 +1622,14 @@ usage(void)
extern char *__progname;
fprintf(stderr,
- "usage: %s [-1Cv] [-B buffer_size] [-b batchfile] [-F ssh_config]\n"
- " [-o ssh_option] [-P sftp_server_path] [-R num_requests]\n"
- " [-S program] [-s subsystem | sftp_server] host\n"
+ "usage: %s [-1246Cqv] [-B buffer_size] [-b batchfile] [-c cipher]\n"
+ " [-F ssh_config] [-i identify_file] [-o ssh_option]\n"
+ " [-P sftp_server_path] [-R num_requests] [-S program]\n"
+ " [-s subsystem | sftp_server] host\n"
" %s [user@]host[:file ...]\n"
" %s [user@]host[:dir[/]]\n"
- " %s -b batchfile [user@]host\n", __progname, __progname, __progname, __progname);
+ " %s -b batchfile [user@]host\n",
+ __progname, __progname, __progname, __progname);
exit(1);
}
@@ -1658,10 +1660,24 @@ main(int argc, char **argv)
ll = SYSLOG_LEVEL_INFO;
infile = stdin;
- while ((ch = getopt(argc, argv, "1hvCo:s:S:b:B:F:P:R:")) != -1) {
+ while ((ch = getopt(argc, argv, "1246hqvCc:i:o:s:S:b:B:F:P:R:")) != -1) {
switch (ch) {
+ /* Passed through to ssh(1) */
+ case '4':
+ case '6':
case 'C':
- addargs(&args, "-C");
+ addargs(&args, "-%c", ch);
+ break;
+ /* Passed through to ssh(1) with argument */
+ case 'F':
+ case 'c':
+ case 'i':
+ case 'o':
+ addargs(&args, "-%c%s", ch, optarg);
+ break;
+ case 'q':
+ showprogress = 0;
+ addargs(&args, "-%c", ch);
break;
case 'v':
if (debug_level < 3) {
@@ -1670,21 +1686,18 @@ main(int argc, char **argv)
}
debug_level++;
break;
- case 'F':
- case 'o':
- addargs(&args, "-%c%s", ch, optarg);
- break;
case '1':
sshver = 1;
if (sftp_server == NULL)
sftp_server = _PATH_SFTP_SERVER;
break;
- case 's':
- sftp_server = optarg;
+ case '2':
+ sshver = 2;
break;
- case 'S':
- ssh_program = optarg;
- replacearg(&args, 0, "%s", ssh_program);
+ case 'B':
+ copy_buffer_len = strtol(optarg, &cp, 10);
+ if (copy_buffer_len == 0 || *cp != '\0')
+ fatal("Invalid buffer size \"%s\"", optarg);
break;
case 'b':
if (batchmode)
@@ -1701,17 +1714,19 @@ main(int argc, char **argv)
case 'P':
sftp_direct = optarg;
break;
- case 'B':
- copy_buffer_len = strtol(optarg, &cp, 10);
- if (copy_buffer_len == 0 || *cp != '\0')
- fatal("Invalid buffer size \"%s\"", optarg);
- break;
case 'R':
num_requests = strtol(optarg, &cp, 10);
if (num_requests == 0 || *cp != '\0')
fatal("Invalid number of requests \"%s\"",
optarg);
break;
+ case 's':
+ sftp_server = optarg;
+ break;
+ case 'S':
+ ssh_program = optarg;
+ replacearg(&args, 0, "%s", ssh_program);
+ break;
case 'h':
default:
usage();