HOWTO: Log in and transfer files to cs-class-1 from MacOS, Linux, or Unix

To establish a connection to cs-class-1 from a Mac or a Linux or Unix machine, we use an ssh client executed from the command line. Instructions for Windows.

  1. On a Mac, launch the Terminal application by going to Applications and then to Utilities. On a Linux box, open the Terminal application. It depends on the distro and the window manager, but check under Applications and Accessories. On the other hand, if you're using Linux, you should already know how to find the terminal.

  2. At the command prompt (%) in the terminal window, type
     % ssh <netid>@class-1.cs.georgetown.edu
     
    where <netid> is your Georgetown Net ID. For example, I would type
     % ssh maloofm@class-1.cs.georgetown.edu
     
    Note that it is possible to configure ssh so you can avoid typing your user name and the full machine name, such as
     % ssh class-1
     
  3. You'll then be prompted to enter your password, and you should enter your NetID password.

  4. This will log you into class-1/cs-class-1, and you'll get another command prompt. From here, you can use an editor, such as nano, vi, or emacs, to create files and g++ to compile them. Here's more information about compiling programs on cs-class-1: HOWTO: Create and compile programs on cs-class-1. Here is more information about common commands: Useful Linux and Unix Commands.

  5. To terminate the session and the connection to cs-class-1, type logout.

Here is a transcript of a short session, with things I've typed set in boldface:

hoya% ssh maloofm@class-1.cs.georgetown.edu
maloofm@class-1.cs.georgetown.edu's password:
Last login: Mon Jan 15 14:50:58 2007 from hoya.georgetown.edu
cs-class-1% logout
Connection to class-1.cs.georgetown.edu closed.
hoya%

To transfer files to cs-class-1 from a Mac or Linux box, from the command-line, you can use sftp or you can download and use Filezilla. To use sftp, navigate to the directory on your computer that contains the files you wish to transfer.

  1. If the target directory exists on cs-class-1 (the remote machine) and you want to transfer all of the files in the directory on your machine (the local machine), then you can use secure copy (scp). If you want to tranfer all of the files for HW1 from a directory named hw1 on your computer–your current directory–to an existing directory named hw1 on cs-class-1, then you can type:
    scp * <netid>@class-1.cs.georgetown.edu:./hw1
    
    A transcript of a sample session when I did this follows:
    hoya% ls
    HONOR main.cpp  main.h  Makefile  numbers.cpp  numbers.h
    hoya% scp * maloofm@class-1.cs.georgetown.edu:./hw1
    maloofm@cs-class-1.cs.georgetown.edu's password: 
    HONOR                                         100%  112     0.1KB/s   00:00    
    main.cpp                                      100%  150     0.2KB/s   00:00    
    main.h                                        100%  115     0.1KB/s   00:00    
    Makefile                                      100%  178     0.2KB/s   00:00    
    numbers.cpp                                   100%  312     0.3KB/s   00:00    
    numbers.h                                     100%  265     0.3KB/s   00:00    
    hoya% 
    
    The asterisk (*) matches all files, but you can also use scp to transfer individual files or smaller groups of files. For example, the command
    hoya% scp main.cpp maloofm@class-1.cs.georgetown.edu:./hw1
    
    transfers only main.cpp to cs-class-1, whereas
    hoya% scp *.h maloofm@class-1.cs.georgetown.edu:./hw1
    
    transfers all the .h files, and
    hoya% scp numbers.* maloofm@class-1.cs.georgetown.edu:./hw1
    
    transfers all of the files that start with "numbers.", which in this case, are numbers.cpp and numbers.h.

    Note that while it is possible to do bulk transfers to a remote machine using scp, it is not possible to do so from a machine unless you have set up passwordless logins.. To do this, you need to use the secure file transfer program (sftp).

  2. If the target directory does not exist on cs-class-1 or you need to do a bulk transfer of files from cs-class-1, then you must use the secure file transfer program (sftp), which lets you transfer files interactively, as well as create, remove, and navigate through directories on both the local and remote machines.

  3. To connect to cs-class-1 using sftp, type
    sftp <netid>@class-1.cs.georgetown.edu
    
    This will establish a connection and prompt you for a password. If you give the correct password, then you get another prompt, the one that sftp presents. For example,
    hoya% sftp maloofm@class-1.cs.georgetown.edu
    Connecting to cs-class-1...
    maloofm@class-1.cs.georgetown.edu's password: 
    sftp> 
    
    By default, sftp sets the current directory to the top-level directory.

  4. Assume that we want to create a new directory for the transfer in the top-level directory. We can use sftp's make directory command (mkdir) to create that directory. For HW1, we would execute:
    sftp> mkdir hw1
    

  5. You will need to use sftp's change directory command (cd) to navigate into the directory where you want to transfer your files. To change to the directory we just created, type:
    sftp> cd hw1
    
  6. To confirm that you are in the proper directory on the remote machine, use pwd, which returns the present working directory:
    sftp> pwd
    Remote working directory: /home/maloofm/hw1
    sftp> 
    

  7. To check that you are in the proper directory on the local machine, you can also use lpwd, which shows the present working directory on the local machine:
    sftp> lpwd
    Local working directory: /home/maloof/cosc052/hw1
    sftp> 
    
  8. Now that you're in the proper directories on the remote and local machines, you can transfer files back and forth. Assuming we want to transfer all of the files from hoya to cs-class-1, type:
    sftp> put *
    Uploading HONOR to /home/maloofm/hw1/HONOR
    Makefile                                      100%  112     0.1KB/s   00:00    
    Uploading Makefile to /home/maloofm/hw1/Makefile
    Makefile                                      100%  178     0.2KB/s   00:00    
    Uploading main.cpp to /home/maloofm/hw1/main.cpp
    main.cpp                                      100%  150     0.2KB/s   00:00    
    Uploading main.h to /home/maloofm/hw1/main.h
    main.h                                        100%  115     0.1KB/s   00:00    
    Uploading numbers.cpp to /home/maloofm/hw1/numbers.cpp
    numbers.cpp                                   100%  312     0.3KB/s   00:00    
    Uploading numbers.h to /home/maloofm/hw1/numbers.h
    numbers.h                                     100%  265     0.3KB/s   00:00    
    sftp> 
    
    As with the scp command, the asterisk (*) matches anything, and in this case, it matches all files. To transfer only main.cpp, type:
    sftp> put main.cpp
    
    To transfer only the .cpp files, type:
    sftp> put *.cpp
    
    To transfer only the .h files, type:
    sftp> put *.h
    
    To transfer main.cpp and main.h, type:
    sftp> put main.*
    
  9. One advantage that sftp has over scp is that we can also retrieve (or fetch) files using the get command. Assume we wanted to transfer all of the files from cs-class-1 to hoya. To do so, type:
    sftp> get *
    Fetching /home/maloofm/hw1/HONOR to HONOR
    /home/maloofm/hw1/HONOR                       100%  112     0.1KB/s   00:00    
    Fetching /home/maloofm/hw1/Makefile to Makefile
    /home/maloofm/hw1/Makefile                    100%  178     0.2KB/s   00:00    
    Fetching /home/maloofm/hw1/main.cpp to main.cpp
    /home/maloofm/hw1/main.cpp                    100%  150     0.2KB/s   00:00    
    Fetching /home/maloofm/hw1/main.h to main.h
    /home/maloofm/hw1/main.h                      100%  115     0.1KB/s   00:00    
    Fetching /home/maloofm/hw1/numbers.cpp to numbers.cpp
    /home/maloofm/hw1/numbers.cpp                 100%  312     0.3KB/s   00:00    
    Fetching /home/maloofm/hw1/numbers.h to numbers.h
    /home/maloofm/hw1/numbers.h                   100%  265     0.3KB/s   00:00  
    
  10. Implementations of sftp usually include online help, which you can access with the help command:
    sftp> help
    Available commands:
    cd path                       Change remote directory to 'path'
    lcd path                      Change local directory to 'path'
    chgrp grp path                Change group of file 'path' to 'grp'
    chmod mode path               Change permissions of file 'path' to 'mode'
    chown own path                Change owner of file 'path' to 'own'
    help                          Display this help text
    get remote-path [local-path]  Download file
    lls [ls-options [path]]       Display local directory listing
    ln oldpath newpath            Symlink remote file
    lmkdir path                   Create local directory
    lpwd                          Print local working directory
    ls [path]                     Display remote directory listing
    lumask umask                  Set local umask to 'umask'
    mkdir path                    Create remote directory
    progress                      Toggle display of progress meter
    put local-path [remote-path]  Upload file
    pwd                           Display remote working directory
    exit                          Quit sftp
    quit                          Quit sftp
    rename oldpath newpath        Rename remote file
    rmdir path                    Remove remote directory
    rm path                       Delete remote file
    symlink oldpath newpath       Symlink remote file
    version                       Show SFTP version
    !command                      Execute 'command' in local shell
    !                             Escape to local shell
    ?                             Synonym for help
    sftp> 
    
  11. Finally, to terminate the sftp session, we use the command quit, which takes us back to the command prompt on the local machine:
    sftp> quit
    hoya% 
    
Here is a complete transcript of a session in which I transfer my files for HW1 to cs-class-1:
hoya% sftp maloofm@class-1.cs.georgetown.edu
Connecting to class-1.cs.georgetown.edu...
maloofm@class-1.cs.georgetown's password: 
sftp> mkdir hw1
sftp> cd hw1
sftp> pwd
Remote working directory: /home/maloofm/hw1
sftp> lpwd
Local working directory: /home/maloof/cosc052/hw1
sftp> put *
Uploading HONOR to /home/maloofm/hw1/HONOR
HONOR                                         100%  112     0.1KB/s   00:00    
Uploading Makefile to /home/maloofm/hw1/Makefile
Makefile                                      100%  178     0.2KB/s   00:00    
Uploading main.cpp to /home/maloofm/hw1/main.cpp
main.cpp                                      100%  150     0.2KB/s   00:00    
Uploading main.h to /home/maloofm/hw1/main.h
main.h                                        100%  115     0.1KB/s   00:00    
Uploading numbers.cpp to /home/maloofm/hw1/numbers.cpp
numbers.cpp                                   100%  312     0.3KB/s   00:00    
Uploading numbers.h to /home/maloofm/hw1/numbers.h
numbers.h                                     100%  265     0.3KB/s   00:00    
sftp> quit
hoya%