|
Softpanorama
(slightly skeptical)
Open Source Software Educational Society |
May the
source be with you,
but remember the KISS principle ;-)
|
SFTP
SFTP is normally used as an intractive application/protocol, but also
can be put into a batch mode with the -b flag. This can be specified with
a file or can be directed stdin from an external script.
The password can not be passed by either process.
sftp [-1Cv] [-b batchfile] [-F
SSH_config] [-o SSH_option] [-s subsystem
| sftp_server] [-S program] host
sftp [[user@]host[:file [file]]]
sftp [[user@]host[:dir[/]]]
But mostly SFTP is used as an interactive file transfer program.
With FTP one might try to copy up all their JPG files to their image
directory like this:
ftp> cd /home/user/images/
ftp> bin
ftp> prompt
ftp> mput *.jpg
With SFTP it is much simpler..
sftp> cd /home/user/images/
sftp> put *.jpgtt>
List of SFTP commands (SFTP will abort if any of the following
commands fail):
- get [flags] remote-path [local-path]
Retrieve the remote-path and store it on the local machine. If
the local path name is not specified, it is given the same name it has
on the remote machine.
- put [flags] local-path [local-path]
Upload local-path and store it on the remote machine. If the
remote path name is not specified, it is given the same name it has
on the local machine.
- rename oldpath newpath Rename remote file from
oldpath to newpath.
- ln oldpath newpath Create a symbolic link from
oldpath to newpath.
- rm path Delete remote file specified by path.
- lmkdir path Create local directory specified by
path.
List of other commands:
- bye Quit sftp.
- exit Quit sftp.
- quit Quit sftp.
- cd path Change remote directory to path.
- lcd path Change local directory to path.
- ls [path] Display remote directory listing of either
path or current directory if path is not specified.
- pwd Display remote working directory.
- rmdir path Remove remote directory specified by
path.
- chgrp grp path Change group of file path
to grp. grp must be a numeric GID.
- chmod mode path Change permissions of file
path to mode.
- chown own path Change owner of file path
to own. own must be a numeric UID.
- symlink oldpath newpath Create a symbolic link
from oldpath to newpath.
- mkdir path Create remote directory specified by
path.
- lls [ls-options [path]] Display local directory
listing of either path or current directory if path is
not specified.
- lpwd Print local working directory.
- lumask umask Set local umask to umask.
- ! command Execute command in local shell.
- ! Escape to local shell.
- ? Synonym for help.
- help Display help text.
SFTP may also use many features of SSH, such as public key authentication
and compression. SFTP connects and logs into the specified host,
then enters an interactive command mode. The second usage format will retrieve
files automatically if a noninteractive authentication method is used; otherwise
it will do so after successful interactive authentication. The last usage
format allows the sftp client to start in a remote directory.
Here are the options used:
- -1 Specify the use of protocol version 1.
- -b batchfile Batch mode reads a series of commands
from an input batchfile instead of stdin. Since it lacks
user interaction it should be used in conjunction with non-interactive
authentication.
- -C Enables compression (via SSH's -C flag).
- -F SSH_config Specifies an alternative per-user configuration
file for SSH. This option is directly passed to SSH.
- -o SSH_option Can be used to pass options to SSH
in the format used in the SSH configuration file. This is useful for
specifying options for which there is no separate sftp command-line
flag.
- For example, to specify an alternate port use: sftp -oPort=26
(UHACC used to use this port config).
- -s subsystem | sftp_server Specifies the SSH2
subsystem or the path for an sftp server on the remote host. A path
is useful for using sftp over protocol version 1, or when the remote
SSHd does not have an sftp subsystem configured.
- -S program Name of the program to use for the
encrypted connection. The program must understand SSH options.
- -v Raise logging level. This option is also passed to SSH.
Once in interactive mode, sftp understands a set of commands
similar to those of ftp. Commands are case insensitive and pathnames
may be enclosed in quotes if they contain spaces.
- -P If the flag is specified, then the file's full permission
and access time are copied too.
Copyright © 1996-2009 by Dr. Nikolai Bezroukov.
www.softpanorama.org was
created as a service to the UN Sustainable Development Networking Programme (SDNP)
in the author free time.
Submit
comments This document is an industrial compilation designed and created
exclusively for educational use and is placed under the copyright of the
Open Content License(OPL).
Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made
for educational purposes only in compliance with the fair use doctrine.
Disclaimer:
- The statements, views and opinions presented on
this web page are those of the author and are not endorsed by, nor do they necessarily
reflect, the opinions of the author present and former employers, SDNP or any other
organization the author may be associated with.
- We do not warrant the correctness of the information provided or its
fitness for any purpose
- In no way this site is associated with or endorse cybersquatters
using
the term "softpanorama" with other main or country domains (e.g. softpanorama.com) with
bad faith intent to profit from the goodwill belonging to
someone else.
Last modified:
August 12, 2009