U.H.A.C.C. Join today! Linux Free BSD OSX (Darwin) Open BSD GNU - Free Software Foundation IBM AIX Sun - Solaris, Open Office SGI IRIX
home club info listserv sysblogd forums geeky links tech help webmail contact
hacker emblem


LDP Mirror
Forums RSS

Past club events:

UHACC @ Penguicon
LinuxFest 2004
SCO-B-Q
UHACC @ Flatcon

Club Pages:

ISU chapter: ISUnix
Member's Sites

Projects:

UHACC CVS

Club Documents:

Our Guiding Principles
UHACC Constitution
Operating Code
Membership App
AUP


Valid CSS!

SFTP How To:

First, what is SFTP?

SFTP is part of the SSH suite. The SFTP acronym stands for Secure File Transfer Protocol.

Additionaly, the OpenSSH suite also includes the SSH program which replaces rlogin and telnet, and the SCP program which replaces rcp.

The daemon included is SSHD, which is the server side of the package. Other basic utilities included are SSH-ADD, SSH-AGENT, SSH-KEYGEN, and SFTP-SERVER.

Like it's unsecured brother, FTP, SFTP's general purpose is to exchange files between a server and client.

OpenSSH supports SSH protocol versions 1.3, 1.5, and 2.0.

So, does UHACC support FTP, SFTP, and SCP?

No. Only the SFTP/SCP protocols

Considering the security threats concerning the plain text FTP protocol, UHACC's official file transfer is SFTP.

How do I SFTP to UHACC?

The suggested way of connecting to UHACC from the command line is to use the following format:

(shellprompt)$ sftp [username]@uhacc.org

Like many other application layer protocols and depending on the OS you are using, SFTP has both command line and GUI interfaces

SFTP is normally thought of as an intractive application/protocal, 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 an interactive file transfer program, as mentioned earlier very similar to FTP, which performs all operations over an encrypted SSH transport.

Below is an example of some noted differences:

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 *.jpg

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.

What about the flags that SFTP uses?

The options are as follows:

-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.

Upcoming Events


UHACC Pre-Meeting


Wednesday Evenings, ~5:15-6:30pm

- Lunker's


Officially unofficial pre-meeting meeting.
Come. Eat. Geek.


UHACC Meeting


Every Wednesday - 7:00-9:00pm

IWU Center for Natural Science Learning and Research, Fishbowl, floor 2. [Directions]



Join us every Wednesday for our usual gratuitous display of geekiness. Meetings are free and attendance is open.

Hope to see you there!


[Home] [Acceptable Usage] [Privacy Policy] [Downloads] [LDP Mirror] [Member's Sites] [Archives]

Copyright © 2006: Unix Hobbyists' Administrators' & Coders' Club. All Rights Reserved.
UHACC, P.O. Box 6376 - Bloomington, Illinois 61702-6376
"First they ignore you, then they laugh at you, then they fight you, then you win." - Mahatma Gandhi