I have put this guide together for reference, but also to help anyone who is intending to work on the UiO servers. It is mostly specific to connecting to the machines from a linux computer, but there may be alternatives for some of the tools I am discussing here. If I know of them, I will try to make reference as appropriate. Feel free to contribute.
First Things First
Let's first take care of a few definitions:
- client / local
- your local machine/computer that is sitting in front of you
- host / remote
- the machine/computer that you are connecting to
- the monitor in front of you
The Client Environment
List of software I use regularly to connect to servers and work on remote machines:
Critical to software programming and working on servers is to have a good editor. I dare not make strong recommendations here, but would suggest that you find one you are comfortable working with. Key features I look for:
- syntax highlighting
- project browser (e.g. a panel that displays project resources next to your editor)
- an object browser (this is getting toward an IDE, but many text editors also have this capacity)
An extremely elegant and highly configurable system that is cross platform, and I've now started to use is sublime-text. It seems quite powerful, is fun to customize, has a **ton** of packages available. OpenSourceHacker provides a nice overview of getting it configured for productivity. I'm a bit concerned over some rumors of ceased development, and it costs 70 dollars, but I think it's already worth it. Let's hope progress continues.
On windows, notepad++ is a good option. For Linux there are many to choose from, and if you're using linux, you probably have a favorite ;)
Shell / Terminal
For linux I think terminator is a terrific environment for working with the command line.
Once connected to the host machine, you may want to invoke screen if you're running a big job. You can also use 'nohup' of course.
Note, if you start to use
screen on the servers, be sure to read: SSHTricks
Connecting to the Servers
In order to make connecting to the servers seemless, it is highly recommended to set up ssh keys. It takes a little bit of time and configuring, but once completed, passwordless login is a breeze, and you'll find using commands such as scp, sshfs, and ssh to be painless. In terms of the choice of ssh utilities, that will largely depend on your OS. For linux, it's built in, but for Windows you'll need to download a client program such as Putty.
Here we'll work through:
- Setting up your ssh keys for passwordless login
- Setting up your ssh connection to forward X displays
1. SSH Keys
Shamelessly take from sourceforge
Goal You want to use Linux and OpenSSH to automize your tasks. Therefore you need an automatic login from userA@local to userB@host (note userA and userB may or may not be the same user). You don't want to enter any passwords, because you want to call ssh from a within a shell script.
First log in to your machine as userA@local and generate a pair of authentication keys:
usera@loca:~> ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/a/.ssh/id_rsa): Created directory '/home/a/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/usera/.ssh/id_rsa. Your public key has been saved in /home/usera/.ssh/id_rsa.pub. The key fingerprint is: 3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
Now use ssh-copy-id to copy over your public key to the remote server:
usera@local:~> ssh-copy-id remote
usera@local:~> ssh-copy-id userb@remote
From now on you can log into remote as userb from local as usera without password:
usera@local:~> ssh userb@remote
Depending on your version of SSH you may also have to do the following changes:
- Put the public key in .ssh/authorized_keys2
- Change the permissions of .ssh to 700
- Change the permissions of .ssh/authorized_keys2 to 640
2. Forward X and use Compression
For linux machines this is easy:
ssh -XC user@remote
For Windows machines it may require a little more work. I have had success in the past with the following tools:
I believe following the instructions to use the Xmingportableputty software should provide you with a working x-server and a ssh client on windows machines to connect to the servers. Note that if give options with the ssh software to forward X connections choose yes, or click the box and do the same with compression.
Start right where you left off
One of the biggest advantages to working on a server is 'context'. Generally, you don't have all the context switching while you are working that you do when you are working on the laptop in front of you. Now, of course, you are probably using a laptop to connect to the server, so it doesn't really make that big a difference. But a nice feature of the server is that --if you follow this Guide -- you'll always be able to pick up right where you left off. That is, the context will be the same as you left it.