Search This Blog

Monday, December 15, 2008

Putty Tips

Putty title
I wanted to change putty title to reflect current working directory of the remote machine to distinguish multiple putty windows easily.

PUTTY_TITLE=`hostname`:`tty | cut -f 4 -d "/"`
export PS1='$PWD>^[]2;$PWD:$PUTTY_TITLE^G'

To insert in vi editor the "^[" character in insert mode press control-V and then the Escape key. ^G is created by pressing control-G.

Passwordless connection to HPUX machines
Since I was forgetting my passwords for HPUX machines, I decided to try SSH public/private key authentication to get rid of passwords. After some struggle I managed to login in to HPUX machines using Putty without entering a password.

Before I forget all those steps which are not part of my daily job, I wanted to log them and so here it is.
  1. Login to HPUX machine using your login and password
  2. Create a .ssh directory under your home directory mkdir .ssh
  3. Create public/private key pair ssh-keygen –t rsa
  4. Add the public key to authorized_keys2 file cat>> authorized_keys2
  5. Now ftp the private key file(id_rsa) to your Windows machine.
  6. Covert the private key file format to putty private key file format. (Use puttygen.exe and then load and save the private key file).
  7. Now in putty, select the host and select SSH as protocol and in SSH options on the left hand tab select Auth and select the private key file.
If you get “server refused our key” error then I would suggest running sshd with debug option. (/usr/sbin/sshd -d -d -d &)

You can also check the permission of your files and folders.
  • chmod 600 authorized_keys2
  • chmod 700 .ssh
  • Also check your home directory permission.
It should work. If it is not, you can try running the ssh client in debug mode from the same server. (ssh -l username servername -v -v -v)

Passwordless connection to Tru64 machines
It is almost same as HPUX configuration but the directory name should be ".ssh2" instead of ".ssh". And it should contain a text file named "authorization"; the contents of that file should be list of public key files separated by newline.
authorization id_rsa_2048_a random_seed
/home/samuel/.ssh2>cat authorization
Someother tools I came to know when I was searching Putty enchancements
  1. I wanted some small utility to avoid digging through Start menu Programsto find Putty or any other program to launch it. I want a small command line kind of utility and found Launchy it can launch any program by typing few letters of that program.
  2. Sometime I start source control/compilation of kernel from my office and want to continue things from my home. But since terminal emulators such as Putty are bound to local machine, I used to open new terminal session or use remote desktop connection to my office machine to continue my work. One of my colleagues told me about GNU screen and how it can solve the problem. Here is some good introduction to screen.
Putty sessions
I was searching for method to launch Putty session quickly and saw the following article Multiple putty addons

Previously I was using "Putty Session Manager" to categorize and lanuch putty sessions.

Enabling colors in vim in putty terminal