2.7.1. sftp
The
scp command is convenient and useful, but many
users are already familiar with FTP (File Transfer Protocol), a more
widely used technique for transferring files on the
Internet.[14] sftp is a separate file-transfer tool
layered on top of SSH. It was developed by SSH Communications
Security and was originally available only in SSH2, but other
implementations have since appeared (e.g., client support in SecureFX
and server support in OpenSSH).
sftp is available
only in SSH2: it is implemented as an SSH2 subsystem [
Section 5.7, "Subsystems"] and thus not readily adaptable to use with
SSH1.
sftp is advantageous for several reasons:
- It is secure, using an SSH-protected channel for data transfer.
- Multiple commands for file copying and manipulation can be invoked
within a single sftp session, whereas
scp opens a new session each time it is invoked.
- It can be scripted using the familiar ftp command
language.
- In other software applications that run an FTP client in the
background, you can try substituting sftp, thus
securing the file transfers of that application.
You may need an agent when trying this or similar FTP replacements,
since programs that use FTP might not recognize the prompt
sftp issues for your passphrase, or they might
expect you to have suppressed FTP's password prompt (using a
.netrc file, for example).
Anyone familiar with FTP will feel right at home with
sftp, but
sftp has some
additional features of note:
- -b filename
- Read commands from the given file instead of the terminal
- -S path
- Locate the ssh2 program using the given path
- -h
- Print a help message and exit
- -V
- Print the program version number and exit
- -D module=level
- Print debugging output [Section 5.8.2.2, "SSH2 Debug mode (module-based)"]
Also,
sftp doesn't have the separate ASCII
and binary transfer modes of standard FTP, only binary. All files are
transferred literally. Therefore, if you copy ASCII text files
between Windows and Unix with
sftp, end-of-line
characters aren't translated properly. Normally, FTP's
ASCII mode translates between Windows' "carriage return
plus newline" and Unix's newline, for example.