Saving SSH session for use in “Terminal”
Secure Shell (SSH) is a cryptographic network protocol for secure data communication, remote shell services or command execution and other secure network services between two networked computers that it connects via a secure channel over an insecure network.
Anyone who use frequently SSH to log into remote servers for regular use, it is very important to use shortcuts that allow for quick login.
For Windows users a combination of PuTTY and a Putty Connection Manager will do the job.
For Mac OS X and *Nix users no need for a SSH client since the “Terminal” application is a built-in. By default to log into your remote servers you use one of these command in your “Terminal”:
ssh [email protected]
ssh terraltech.com -l user
After this, it prompts you for your password!!!
Not very complicated when it comes to one server, if you have 10, 20 or more servers…More complicated to keep in mind all the passwords and the remote server’s address plus the waste of time.
I have a solution for you, lets create some shortcut for these command
On your local computer start the Terminal and open the profile file for the current user
Enter a new line for your shortcut
alias t='ssh -2 [email protected]'
The letter “t” is the shortcut to connect to terraltech.com server.The “-2″ is to force SSH2 con¬≠nec¬≠tions instead of older SSH.
Now save the file and source to try it out.
The profile has the alias t now, but it will prompt for the password!
Generate public and private keys and leave the passphrase empty (simply press ENTER when asked for it).
If the directory .ssh doesn’t exist you can create it like this
Copy the public key to the remote computer, change “user” to your user name and change “host” to your domain name
scp ~/.ssh/id_rsa.pub user@host:~/
Log on to the remote computer
Create the .ssh directory in the root login directory, if it doesn’t already exist
Append the key to file
cat id_rsa.pub >> ~/.ssh/authorized_keys
Delete the public key file, no longer needed
rm -f id_rsa.pub
Log off the remote server
Logon to the remote server, without password prompt
Wow! that’s it, it’s a huge timesaver. Now all I need to do is type “t” in the Terminal to connect to the terraltech.com server. Use these instruction for each hosts.