This are my notes in the fields of computer science and technology. Everything is written with ABSOLUTE NO WARRANTY of fitness for any purpose. Of course, feel free to comment anything.

Showing posts with label connection to remote servers. Show all posts
Showing posts with label connection to remote servers. Show all posts

Sunday, October 11, 2009

Starting ssh-agent from .tcshrc

While connecting to a server using SSH, you need either to provide a password or to use a public-private key pair to identify yourself. The latter is interesting, as you don't have to write your password each time. A copy of the public key must be saved in the computer acting as ssh server under ".ssh/authorized_keys", the private key stays only on the client computer.

However for security reasons it is strongly reccomended to set a password on the key file. Otherwise anyone who can steal your key somehow (like accessing your computer physically), can steal your identity. But if your key file has a password, then you would have to write the password each time, so it wouldn't be much better than using passwords instead of keys in the first time. Luckily there is a solution: ssh-agent and ssh-add. ssh-agent runs as a deamon and remembers the password to your key. ssh-add allows you to tell ssh-agent the password.

As ssh-agent keep running when you log off your session, you may add some lines to your shell startup script, to test if ssh-agent is running, otherwise to start it and ask you the password (via ssh-add). In the github guides there is a script for bash (). I adapted it to use it in tcsh, which I use as a shell. Here is it (I added these lines at the bottom of my .tcshrc file, only *before* setting the prompt explicitely, as I used it to distinguish interactive sessions from non-interactive ones):

# start ssh agent if not started yet
set SSH_ENV = "$HOME/.ssh/environment"
unset SSH_AGENT_RUNNING
if (-f $SSH_ENV) then
source $SSH_ENV
ps $SSH_AGENT_PID > /dev/null && set SSH_AGENT_RUNNING
endif
if ($?prompt && ! $?SSH_AGENT_RUNNING) then
echo "Initializing SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' >! $SSH_ENV
chmod 600 $SSH_ENV
source $SSH_ENV
echo "done: ssh-agent is now running, PID $SSH_AGENT_PID"
/usr/bin/ssh-add
endif

Sunday, September 13, 2009

PuTTY

A terminal emulator using ssh or telnet connections to remote servers. I always use this for ssh connections from a Windows machine to a Linux machine (usually using WinSCP for file exchanges) - including my virtual linux server I run in background.

In Windows the program settings (including the saved sessions) are stored in the registry at the position: Computer\HKEY_CURRENT_USER\Software\SimonTatham\PuTTY .

Developer: Simon Thatam
Version: 0.60 (April 29, 2007)
Platform: cross-platform
License: open source

Saturday, September 12, 2009

WinSCP

WinSCP is the perfect windows tool to connect to remote servers and exchange (download/upload) files or edit them. It is a SFTP and FTP client.

There is a standalone version and an installer based setup; if using the latter, beware that it will ask you install additional software using the OpenCandy system. However at least the default is not to install any additional software.

I like to store the preferences in ini file instead of the registry, so that I can export them easily to other computers. To turn on the ini preferences storage: in WinSCP login dialog select "preferences", then "Other general options: Preferences", "Storage" and change the "configuration storage" value to "INI file". The default location of the ini file under Windows Vista will be: "C:\Users\\AppData\Local\VirtualStore\Program Files\WinSCP". Under older Windows version it will be directly in the application directory (C:\program files\WinSCP).

Version: 4.2.3 beta (August 18, 2009)
Platform: Windows
License: freeware

About Me

My photo
Hamburg, Hamburg, Germany
Former molecular biologist and web developer (Rails) and currently research scientist in bioinformatics.