WorkingOnServers/JFBsWorkFlow

From mn/geo/geoit
Revision as of 10:53, 15 September 2011 by Jfb (talk | contribs) (1. SSH Keys)

Jump to: navigation, search

This is a tip contributed by Jfb 15:34, 14 September 2011 (CEST)

I have put this guide together for reference, but also to help anyone who is intending to work on the NILU servers. It is mostly specific to connecting to the machines from a linux box, 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.

Firs 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
display
the monitor in front of you

The Client Environment

List of software I use regularly:


Editors

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)

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.

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:

  1. Setting up your ssh keys for passwordless login
  2. 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

OR

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