ssh without a hostname and password

15/06/2011

Often I have to login to different machines. It’s annoying to always type the full hostname and then password. So here is what you can do to avoid typing too much:

1. On your local machine create a private and public key:

ssh-keygen -t rsa

by default 2 keys will be created (id_rsa, id_rsa.pub) under ~/.ssh

2. Create config file under ~/.ssh

touch ~/.ssh/config

3. Add your connection information to config file:

Host HOST_ALIAS # can be anything you want
Hostname HOST_NAME # example.com
User USERNAME
port PORT

4. Create .ssh folder on the remote machine from your local machine (you will be prompted for the password):

ssh HOST_ALIAS mkdir -p .ssh

5. Finally append your new public key id_rsa.pub to ~/.ssh/authorized_keys on your remote machine (you will be prompted for the password one last time):

cat ~/.ssh/id_rsa.pub | ssh HOST_ALIAS 'cat >> .ssh/authorized_keys'

That’s all! Now every time you want to login to your remote machine you can type:

ssh HOST_ALIAS

and you should be able to get in.

No Comments

how to remove .svn from all folders – command line

15/10/2008
find . -name ".svn" -exec rm -rf '{}' \;
No Comments