CCIT

UA Home CCIT Home UA Search

Using SSH on Mac OS X

Revised Feb 14 2003

Steps for using SSH from OS X:

On your Mac from the pulldown under Go:
  1. Select Applications
  2. Open the Utilities folder
  3. Double-click the Terminal utility to start it
  4. In the command-line (versus graphical) interface window enter
    ssh NetID@u.arizona.edu
    where NetID is your username on the U-System. You will be prompted for your password. At this point you are actually logged in to Unix running on the U-System. (All of these commands apply to other systems requiring SSH, such as Super.)
  5. Use sftp (Secure FTP) and scp (Secure Copy) in the Terminal window to get and put files to and from the U-System. You do not need to be logged in to the U-System (#4, above) to copy files; scp and sftp will prompt you for your U-System password. (There are lots of examples of sftp and scp below.)

Transferring Files

Fugu is University of Michigan software that provides a graphical alternative to file-transport commands like sftp and (unlike Fetch below) requires no tunnel. Very simple and straight-forward.

Applications like Fetch and GoLive need to tunnel SSH to communicate with and copy files to the U-System.

Some Fundamental Unix Commands for Mac OS X

The Terminal utility (#3) is a Unix-command interface that you can use to manage your Mac's files, run Unix applications and connect to other (remote) systems. Here are some Unix commands that you'll find handy if you're new to Unix:
  • to list your local (Mac) files, do ls
  • to remove a file on your Mac, do rm filename (you can still drag it to Trash)
  • to make a directory, use mkdir dirname (you can still use Finder to make a New Folder)
  • to remove a directory, rmdir dirname
  • to show where you are, Print your Working Directory path, pwd
  • to copy (duplicate) a file on you Mac, cp source-file destination-file
  • to move a file to a new location or rename it, mv source-file destination-file
    (source-file will no longer exist)
  • pico, which is on the U-System also, can be used to edit files
  • to display a file without actually opening to edit it, do more filename
  • display the online manual for any of these commands by using the man command,
    like man ssh
  • for information on using and controlling the Terminal utility, see Terminal's Help pulldown
  • for a list of Unix commands, grouped by function, with explanations and examples, see the U-System's webpage of SunOS Unix Commands.
If you use SSH to connect to the U-System or Super, most of the Mac Terminal commands work on those systems so you must be alert to which system is prompting you so that you don't modify files in the wrong location.

SSH-related Commands under Mac OS X

"SSH" refers to both the client software that allows secure communications and the command that is used to do logins to remote systems. If your userid on your Mac (whoami), is the same as your NetID on the U-System, you can use ssh, scp and sftp without entering your NetID in the command--the SSH client will pass it to the SSH server on the U-System.
    SSH
    • ssh NetID@u.arizona.edu
      You'll be prompted for your password. When you are logged in to the U-System, you will see your usual Shell or Menu interface. Be sure to exit from the U-System when finished.
    • ssh u.arizona.edu
      This is all you will need if your Mac ID is the same as your NetID.

    SCP
    SCP "pushes" a file from its source to its destination.

    • scp source-file NetID@u.arizona.edu:destination-file
      You'll be prompted for your U-System password then source-file will be copied to the destination-file, which is "remote" in this case--residing on the U-System.
    • scp NetID@u.arizona.edu:source-file destination-file
      The source-file, which is "remote" in this example, will be copied to create a destination-file on your Mac.
    • scp abc-file u.arizona.edu:
      The file abc-file on your Mac will be copied to the U-System with that same name after you're prompted for your password.
    • The -r option of scp can be used to recursively copy a directory and its substructure. When using this, you only specify a directory as your "source-file"; the destination is the name for the new directory that will be created.
    • The -p option of scp is used to preserve the access permissions of the source-file. Otherwise, the destination-file will have the permissions of the destination parent.
    Notice that scp's format always has the existing file first and the to-be-created file second regardless of whether each file is on your Mac or remote.

    SFTP
    sftp NetID@u.arizona.edu
    You'll be prompted for your password. Then SFTP enters interactive mode (you'll see a command prompt that looks like sftp>). With sftp you use the command get to bring a file to your Mac and put to place a file on the remote system.

    • help
      This gives you a list of the commands and their formats that you can use in your sftp session. The change-directory command, cd, works with the Terminal utility to point to a different subdirectory on the U-System, pwd shows you the current directory.
    • get remote-path [local-file]
      Copies the file specified as remote-path to your Mac. It will use the remote name for the file unless you override it by providing a local-file name.
    • put local-file [remote-path]
      Copies local-file from your Mac to your current directory on the remote host. You can override the local-file name by specifying remote-path.
    • quit or bye
      To end your sftp session and your connection to the U-System.

  • You should verify the access permissions of any files you place on the U-System, especially if you are putting webpages there. The easiest way to verify webpage permissions is to try to view the page with a browser. If you get a "...do not have permission" error message:
    For Shell-mode access:
    • ssh NetID@u.arizona.edu to log in to the U-System
    • Enter your password
    • cd public_html to get to the subdirectory where your webpages are
    • wwwaccess to set permissions for all files in your public_html directory (this is a locally developed command)
    • exit
    For Menu-mode access:
    • ssh NetID@u.arizona.edu to log in to the U-System
    • Enter your password
    • Choose the Misc option
    • Choose Home Page
    • Choose Permission
    • Once you are finished on the U-System, enter q to Quit

  • When you have finished with the Terminal utility, choose Quit from the pulldown to stop the utility or minimize the window until the next time you need it.

Miscellaneous Mac OS X/Unix Tips and Examples

In your Mac's Terminal window (not running SSH to talk to the U-System):
  • To copy a file from your default directory on the U-System to the default directory on your Mac (subdirectory Users/your_folder)
    • sftp NetID@u.arizona.edu
      You do not need your NetID in the command if it is the same as your Mac userid. You'll be prompted for your password.
    • get .tcshrc
      Gets your U-System tcsh RC file and copies it back to your Mac. Although all of your SunOS settings may not be useful on the Mac, there are some sample entries that would have application for OS X.
  • On your Mac to copy (using SFTP) a file from your Mac, from Users/your_folder/Documents, to public_html in your U-System account
    • sftp u.arizona.edu
      You could use this command if your NetID and Mac userid are the same. You'll get a prompt for your password.
    • put Documents/file1.html    public_html
  • On your Mac to copy (using SCP) a file from your Mac, from Users/your_folder, to your U-System account
    • scp local_file   u.arizona.edu:remote_file
      You'll get a prompt for your password.
  • On the U-System to copy (push) a file from the U-System to your Mac, you would first need to open System Preferences (under the Apple pulldown), under Internet & Network, click Sharing, click the Application tab and select "Allow remote login" so that you can log in back to your Mac from the U-System to copy files. Then
    • scp u-system-file   your-Mac-username:mac-file
      You'll get a prompt for your Mac password.

Useful Things for Your Mac's RC File

  • Either edit the RC file you copied above or edit it to create one, like
    pico .tcshrc
  • Make shortcuts ("aliases") like the following:
    alias utunnel 'ssh -l NetID -L 1024:u.arizona.edu:21 u.arizona.edu'
    • Replace NetID in the command with your NetID.
    • Next time you start a Terminal or new shell window on you Mac, execute this alias to set up an SSH tunnel for Fetch or GoLive so that you can copy files to the web server (u.arizona.edu).
    • Execute the tunneling alias by issuing the command     utunnel
      This logs you in to the U-System so you will be prompted for your password.
    alias cp 'cp -i'
    alias mv 'mv -i'
    alias rm 'rm -i'
      The -i option in these last 3 aliases will make synonyms for cp, mv and rm so that you will be asked for approval, file-by-file, before the Copy, Move, or Remove command proceeds.

SSH on Mac OS X
UA Homepage      CCIT Homepage


The Center for Computing & Information Technology (CCIT)
CCIT Knowledgebase
Telephone: 621-HELP
Email: Consult@listserv.arizona.edu

Website maintained by:
CCIT Computing Services