SSH Key Access"> Course Account SSH Key Access

We use ssh and public keys to provide access to course accounts.

This is background information on using SSH public keys to authenticate as a course account. Looking at that document first is recommended.

CSCF has deployed an automated tool to propagate ssh keys to course accounts from home directories in the student region (i.e. one of the systems). Authorized users of a course account will be able to ssh and scp from their preferred workstation into the course account, after a one-time key copy to their own student-environment account. An automated check for new keys happens once an hour.

For answers to questions about this process, contact DanielAllen.

Setup Instructions for Course Accounts Users

  • Create a ssh key on the preferred machine(s) you usually work from, whether inside or outside UW, and copy the public key file to
  • If you have no other suitable computing environment, you can set up your ssh key directly on linux.student.cs.uwaterloo,.ca. Log in (see above if you need to set/reset the password) and issue the command: ssh-keygen.
  • If this is a new user for the course account, notify the course manager or your CSCF course contact to have the .rhosts file updated.
  • If this is a current user for the course account, the automated key-propagating tool will copy the key within an hour.
  • You may now log in from your preferred machine to the course account using the command: ssh

Questions and Answers

Q: I've generated a key. Can I get more detail about copying the key to

From Unix/Linux, try ssh-copy-id and it should be copied over correctly.

From any OS: use copy and paste:

  • From Mac/Unix/Linux, look for your key in ~/.ssh/
  • From Windows, see here for details about finding the key's location.
  • Select and copy the entire key. It will look something like:
        ssh-dss AAAAB3NzaC1kc3MAAACBAKAtgLEWHkwKJOjVUVvBEjpYE172mcoJkMyuX6kHSY7ZayF760+0
        [5 lines deleted]
        Yjm0P02TeCMO7KTezbVKSFrEeg== daniel@zot.local
  • It must have no carriage-returns in it. (the above is reformatted for display).
  • log into via your preferred means (ssh or rlogin)
  • create the .ssh subdirectory if it doesn't exist:
    • mkdir ~/.ssh
  • paste the key:
    • cat >> ~/.ssh/ [carriage-return] [paste the key] [ctrl-C]
  • It must be pasted all on one line. Use an editor to remove any carriage-returns.
If you already have a different key on the student-region host, see the second part of the following question.

Q: What if I use more than one home workstation/machine to access course accounts? Which part of this do I repeat?

You have two choices:

  • create one key, which you will copy to the additional workstations. You must copy both halves ( id_dsa and to the other machines' ~/.ssh directory (creating the directory if necessary). Ssh from both machines will now identify to other machines with the same identity. This is the simpler approach, and is acceptable if each machine you work from has equivalent levels of security / risk of someone stealing the private key.
If one is less trusted and/or you want to keep the private keys separate, you can:

  • create different keys for each machine.
  • Then, copy and paste the each key to the end of the following file on $HOME/.ssh/authorized_keys
    • Each key must go on a separate line of the file. Your authorized_keys will look something like this:

        % cat ~/.ssh/authorized_keys
        ssh-dss AAAAB3NzaC1kc3MAAACBAKAtgLEWHkwKJOjVUVvBEjpYE172mcoJkMyuX6kHSY7ZayF760+0
        [5 lines deleted]
        Yjm0P02TeCMO7KTezbVKSFrEeg== daniel@zot.local
        ssh-dss AAAAB3NzaC1kc3MAAACBAM/a0SBDrtC5iDXRKTrkFK57+h6QyH3WeTGKLhBSF0mkxwuVE6L2
        [5 lines deleted]

Note that each key is copied as one line, which you can check by running word-count on the file:

        % wc -l ~/.ssh/authorized_keys
               2 /u1/yourusername/.ssh/authorized_keys

The number in the response ("2" above) must match the number of keys you copied; otherwise, the key was copied with embedded carriage-returns which must be edited out.

Also note that all core-region servers (cpu1XX.cs) count as "one machine" and separately all of student-region counts as "one machine", because your home directory is shared among regional machines. If you work on cpu102.cs and cpu104.cs, you only have one key to copy to

Q: If I generate a key on my home machine, is this an additional security risk? If someone steals my private key, can they access my home machine?

No, the relationship with keys is not symmetric: unless you run ssh daemon on your home machine, and add the key to your home machine's $HOME/.ssh/authorized_keys file, there is no additional risk to your home machine.

If your private key is stolen, the public key must be removed from authorized_keys on any host it is used on, because it does allow access to those hosts.

If you use a passphrase with your ssh key you have additional assurance that if your private key is stolen, you can replace it before your accounts are broken into.

Q: Is there a way around re-typing your passphrase every time you use the public key?

Yes. See this bit about caching your passphrase.

Q: Specifically which locations for keys are checked by the automated system?

Keys copied from the following standard key locations in the user's .ssh directory:,,, authorized_keys, and authorized_keys2. If you happen to be working with a "course testing account" (ending in -t or t), only,, and are checked, and only for the course-account corresponding to the testing-account's course-name.

Q: What does the automated key copier do?

  • The key copier first checks the .rhosts and .shosts files for each course-account and identifies all users. It then checks for the existence of updated keys in the home directory of each user. If the user's key information is more recent than the last automated update, it will copy the current set of keys to the course account.
  • Updates are copied to the course account's .ssh/.authorized_keys file, which has two sections; a manually-edited section and an auto-updated section. The manually-edited section is more authoritative and is not touched by the automated system. The sections are separated by an comment which warns that changes below that point in the file will be overwritten.
Q: Is there more detailed information about how to use the ssh command?

Yes; for detailed information, see manpages on the student-region hosts: man ssh for logging in, and man scp for copying files (or PuTTY and WinSCP on Windows).

CSCF Administration

See CourseAccountSshKeyAccessAdministration

-- DanielAllen - 07 Jan 2009

Edit | Attach | Watch | Print version | History: r29 < r28 < r27 < r26 < r25 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r29 - 2013-11-02 - DanielAllen
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback