oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Unix on Panther: Accessing the Internet
Pages: 1, 2, 3

SFTP: FTP to secure sites

If you can only use ssh to connect to a remote site, chances are it won't support regular FTP transactions either, probably due to higher security. Mac OS X also includes a version of ftp that is compatible with the standard SSH server programs and works identically to regular FTP. Just type sftp at the command line. Here's an example:

$ cd downloads
$ sftp
Connecting to
The authenticity of host ' (' can't be 
RSA key fingerprint is d0:db:8a:cb:74:c8:37:e4:9e:71:fc:7a:eb:d6:40:81.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ',' (RSA) to the list 
of known hosts.'s password: 
sftp> cd mybin
sftp> dir -l
drwxr-xr-x    0 24810    100          1024 Jun 26 20:18 .
drwxr-xr-x    0 24810    100          1536 Sep 16 18:59 ..
-rw-r--r--    0 24810    100           140 Jan 17  2003 .library.account.
-rwxr-xr-x    0 24810    100          3312 Jan 27  2003 addvirtual
-rw-r--r--    0 24810    100           406 Jan 24  2003
-rwxr-xr-x    0 24810    100          1841 Jan 24  2003 unpacker
-rwxr-xr-x    0 24810    100           946 Jan 22  2003 
sftp> get webspell
webspell                                100%  946     4.7KB/s   00:00    
sftp> quit
$ ls -l webspell
-rwxr-xr-x  1 taylor  taylor  946 25 Sep 11:28 webspell

FTP with a web browser

If you need a file from a remote site, and you don't need all the control that you get with the ftp program, you can use a web browser to download files using anonymous FTP. To do that, make a URL (location) with this syntax:


For instance, specifies the file 2001.pdf from the directory /pub/reports on the host In most cases, you can also start with just the first part of the URL—such as—and browse your way through the FTP directory tree to find what you want. If your web browser doesn't prompt you to save a file, use its Save menu command.

NOTE: If you are using the Safari browser, it will open ftp: directories by mounting them in the Finder.

An even faster way to download a file is with the curl (copy from URL) command. For example, to save a copy of the report in the current directory, simply enter:

$ curl -O

Without the -O option, curl will display the file in the Terminal window. If you want to read a text file from an Internet server, you can combine curl and less:

$ curl | less

You can also use curl with web pages, but this will bring the page up in HTML source view:

$ curl | less

Other FTP solutions

One of the pleasures of working with Unix within the Mac OS X environment is that there are a wealth of great Aqua applications. In the world of FTP-based file transfer, the choices are all uniformly excellent, starting with Fetch, NetFinder, Transmit, FTPeel, rbrowser, and Anarchie, and encompassing many other possibilities. Either open the Apple menu and select "Get Mac OS X Software . . . ", or try VersionTracker (see, Mac OS X Apps (see, MacUpdate (see, or the shareware archive site (see

Easy Shortcuts with Connect to Server

The Terminal application has a very helpful feature that can make connecting to remote systems via telnet, ssh, ftp, or sftp a breeze, once it's set up. Connect To Server is available off the File menu and is shown in Figure 8-4.

Figure 8-4. Connect to Server offers simple shortcuts

To add a service, click on the + icon on the left side of the window. More commonly, you'll add servers, which you can do by clicking on the + icon on the right side of the window. It produces a window that asks for the hostname or host IP address, which is easily entered, as shown in Figure 8-5.

Figure 8-5. Adding a New Server to Connect to Server

Once added in one area, the new server is available for all services, so to connect to Apple's anonymous FTP archive site, choose ftp, then the new server name, and then enter ftp into the User box, as shown in Figure 8-6.

Figure 8-6. Specifying user ftp on ftp connections to

Finally, the connection to Apple's server is a breeze: specify the server, specify the user, and click on Connect. The results are shown in Figure 8-7.

Figure 8-7. Instant connection to Apple's ftp server


You can practice your ftp skills by connecting to the public FTP archive Log in as ftp with your email address as the password, then look around. Try downloading a research paper or document. If you have an account on a remote system, try using rcp and scp to copy files back and forth.


[1] In ssh, you can run an agent program, such as ssh-agent, that asks for your passphrase once, then handles authentication every time you run ssh or scp afterward.

[2] Quotes tell the local shell not to interpret special characters, such as wildcards, in the filename. The wildcards are passed, unquoted, to the remote shell, which interprets them there.

Dave Taylor is a popular writer, teacher and speaker of business and technology issues. The founder of The Internet Mall and, he's been involved with UNIX and the Internet since 1980. He's also been a Mac fan since the year it was released.

Brian Jepson is an O'Reilly editor, programmer, and co-author of Mac OS X Panther for Unix Geeks and Learning Unix for Mac OS X Panther. He's also a volunteer system administrator and all-around geek for AS220, a non-profit arts center in Providence, Rhode Island. AS220 gives Rhode Island artists uncensored and unjuried forums for their work. These forums include galleries, performance space, and publications. Brian sees to it that technology, especially free software, supports that mission. You can follow Brian's blog here.

Return to Mac DevCenter