ug4
SSH

Exchanging SSH Keys

You can exchange RSA keys so you don't have to type in your password every time you connect.

  • generate local ssh key (empty password):
    ssh-keygen -b 2048 -t rsa
  • copy local ssh key to cluster.de (user mrupp):
    cat .ssh/id_rsa.pub | ssh mrupp@cluster.de 'umask 077; cat >> .ssh/authorized_keys'

SSH Controlmaster

Some systems don't support exchange of RSA keys, and some might find it insecure. There's another possible way so you only have to enter your password once for each session. Create the directory ~/.ssh/controlpath and add the following lines to your ~/.ssh/config file:

host *
    controlmaster auto
    controlpath ~/.ssh/controlpath/ssh-%r@%h:%p

You might have to replace ~ with the complete path to your home directory. With this, a ssh connection is "reused" by all later connections. So when you always keep one connection open, you don't have to reenter your password for new ssh terminals or scp transfers.

Note
Your first ssh connection has to include a -X to use X11.
When something is going wrong, you might have to kill all ssh/scp/sshfs processes to restart.

SSH Hopping

Many supercomputers are only accessible by some fixed IP you specify. Since at home we do not have a fixed IP, you have to use SSH hopping. Say speedo's IP (speedo.gcsc.uni-frankfurt.de) is specified as the connecting IP, and your account is mrupp@speedo.gcsc.uni-frankfurt.de, and rupp@supercomputer.de is the supercomputer account. Then you can connect to speedo via ssh, and from there further with ssh to the supercomputer:

ssh mrupp@speedo.gcsc.uni-frankfurt.de
ssh rupp@supercomputer.de

There are two ways to speed this up

  • hopping in one line:
    ssh -t mrupp@speedo.gcsc.uni-frankfurt.de ssh rupp@supercomputer.de
  • automatic hopping: Add the following lines to the file ~/.ssh/config
    Host supercomputer.de
    User rupp
    ForwardAgent yes
    ProxyCommand ssh mrupp@speedo.gcsc.uni-frankfurt.de nc %h %p
    now you'll only have to enter
    ssh supercomputer.de
    and enter the passwords.

FUSE/SSHFS

Manipulating files on remote system can be really tedious. Fortunately, with SSHFS you can mount filesystems over ssh into your computer. It's like having a supercomputer as a USB stick. For that

  • MacOS >= 10.7: download & install OSX Fuse and then SSHFS.
  • MacOS <= 10.6: download & install macfuse.
    install sshfs:

    cd ~/Downloads/
    svn co http://macfuse.googlecode.com/svn/trunk/filesystems/sshfs/binary sshfs-binaries
    cd sshfs-binaries/
    sudo cpsshfs-static-leopard /usr/bin/sshfs

    For tiger, use sshfs-static-tiger.

Now FUSE/SSHFS is installed. Now we'll mount the home directory of mrupp@supercomputer.de to ~/sshvolumes/mrupp@supercomputer.

mkdir ~/sshvolumes
mkdir ~/sshvolumes/mrupp@supercomputer
sshfs mrupp@supercomputer.de: ~/sshvolumes/mrupp@supercomputer -o auto_cache,reconnect,volname=mrupp@supercomputer

unmounting is done via

umount ~/sshvolumes/mrupp@supercomputer
Note
SSHFS also works together with SSH Hopping and Exchanging SSH Keys. For Windows, try Dokan library.

SSHFS + Eclipse

Note for Eclipse users: You can also import a project on your mounted filesystem. For that, create a C/C++ project and as base directory you use the ug4 base directory. You'll then even get SVN info. You can also build on the remote server, but don't use the normal build command: Right Mouse click on the project -> Properties -> C/C++ Build. Disable "use default build command", then enter at "Build Command" something like

ssh mrupp@supercomputer.de "cd ug4; cd release; make -j4"

(You can do the same for run/debug settings).

An improved version is

/bin/bash ${ProjDirPath}/scripts/shell/sshfsmake mrupp@supercomputer.de ug4/debug /Users/mrupp/ug4/debug /Volumes/mrupp@supercomputer/ug4/debug  -j4 -k

See ug4/scripts/shell/sshfsmake for details (basically you are calling ssh mrupp@supercomputer.de "cd ug4/debug; make -j4", and then substituting remote paths with local ones, so Eclipse knows which files contain errors).

Since SSHFS is not as fast as your local drive, you might want to disable the most bandwith consuming things (at Project Preferences):

  • C/C++ Build -> Discovery Options: Disable "Automated discovery of paths and symbols"
  • C/C++ Build -> Logging: Disable Logging
  • C/C++ General -> Indexer -> Disable Indexer

If that does not help, consider Eclipse -> Preferences -> Team -> SVN -> Performance, altough deactivating "deep outgoing state" is not recommended.
Remember that Eclipse does not know that the files are not on your local machine, so when you are doing big SVN checkouts in Eclipse, all data is going to your computer, and then to the remote machine. Consider using the remote shell for those tasks.

See also secSSH_outdatedSVN.