To generate SSH public and private key pairs on Windows, one of the easiest tools to use, is the PuTTY Key Generator “puttygen.exe” (which can be downloaded from here).
The resulting generated files from the PuTTY Key Generator can be used to set up public key authentication with a remote server, allowing for more secure authentication over normal password based authentication (requires disabling password based authentication).
Download the PuTTY Key Generator
You can download puttygen from the following url:
https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
Run puttygen.exe
When puttygen has loaded you will be presented with a screen such as this:
Generate the public and private keys
Click the “Generate” button on the main window to start the process of generating the key data.
While this is happening, you will need to move your mouse around in the blank area at the top of the application. This is used to help randomize the data used to generate the keys.
Once the progress bar has gone through, the public and private key data will have been generated, and you are ready to save the keys.
Saving the public and private keys
Public Key:
Simply press the “Save public key” button. This will be used on the remote host you want to be able to connect into remotely, using the private key.
Private Key:
You have the option to enter a passphrase if you want to make the key more secure. Enter that in, and the confirmed passphrase.
After thats done (or if you dont want to use a passphrase), simply press the “Save private key” button. Store this key in a safe place.
Using the private key in PuTTY
For information on how to use the private key file in PuTTY, please check the following page:
Using SSH Private Key Files with PuTTY
The following guide shows you how to log into a remote server using your private key file. It assumes you already have the associated public key already added into the remote hosts authorized_hosts file.
Download PuTTY
Download PuTTY if you don’t have it installed yet.
You can download PuTTY from the following url:
https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
Open PuTTY
Run Putty.
You should be presented with a screen like this:
Enter in the host name or IP address of the host you want to connect to now, ready to go onto the next step.
Select private key file
Browse the category tree on the left to Connection -> SSH -> Auth
Press browse, and select your private key file.
Connect to remote server
All that’s left to do now, is to press the “Open” button.
You will be asked for the login username as per normal. You will then be asked for the private key passphrase. If you didn’t set a passphrase, you should now be logged into the server.
PuTTY is a popular SSH client for a variety of operating systems. You can set up the window title in the configuration options, but sometimes you may want to display your own information in the window title text.
PuTTY lets you do this via escape commands. More specifically by using the ^[ (escape) and ^G (bell) escape commands.
The ^[ escape code in ansi format is “\033]0;”.
The ^G escape code in ansi format is “\007 “.
To set the window title to “testing” you would echo the “\033]0;” escape command, the word “testing”, and then the “\007” bell command.
Eg:
echo -ne "\033]0;testing\007"
Now, you might find that it doesn’t actually change the title. By default, some Linux distributions set up their own escape commands, to set the host name, and current path in the window title. This is fine for most users, but if you want a bit more control, you may find that any escape commands you run, don’t appear to update the title.
It is actually setting the title to your custom string, but straight after, it is setting it back what they set it to, so it looks like it doesn’t change.
This is due to them setting the prompt_command variable, (which runs after every command), or embedding it in the PS1 variable, which produces the prompt text.
Default “PROMPT_COMMAND” variable in CentOS:
printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"
Default PS1 variable in Ubuntu:
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
Run either of the following commands to check how your distribution might be setting the window title:
echo $PROMPT_COMMAND
or
echo $PS1
To make the changes permanent, you will probably need to edit the .bashrc script in your home directory.
Below are some examples of setting the PuTTY window title:
Ubuntu:
Output the uptime and load average in the window title:
PS1="\[\e]0;`uptime`\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ "
Output the hostname in the window title:
PS1="\[\e]0;`hostname`\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ "
CentOS:
Output the uptime and load average in the window title:
PROMPT_COMMAND='printf "\033]0;Uptime: %s\007" "`uptime`"'
Output the hostname in the window title:
PROMPT_COMMAND='printf "\033]0;%s\007" "`hostname`"'
Output the logged in username, the hostname, and kernel details:
PROMPT_COMMAND='printf "\033]0;%s@%s - %s\007" "`whoami`" "`hostname`" "`uname -s -r`"'
More information can be found at the following links:
http://en.wikipedia.org/wiki/ANSI_escape_code
http://www.chiark.greenend.org.uk/~sgtatham/putty/