Youry's Blog

Youry's Blog

Auto SSH Login without Password

leave a comment »

1. ssh tuneling http://www.revsys.com/writings/quicktips/ssh-tunnel.html

2. How to check tunnel: http://wiki.metawerx.net/wiki/SSHTunnel

Not everything work in Fedora, but this one works very good, at least in the Fedora 13. Good paper
http://linuxtoolkit.blogspot.com/2009/05/auto-ssh-login-without-password.html
Steps 1: At the Host Machine
1. Logon to the root home directory.
2. Make sure the hidden .ssh directory has the permission 700. If not execute the command
chmod 700 .ssh
3. Change Directory to .ssh directory by executing the command
cd .ssh
4. Generate the public-private keys using the ssh-keygen command.
# ssh-keygen -t rsa
5. The resulting file id_rsa and id_rsa.pub rsa type public key
# ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host -> Copy the public key to the remote server:

scp ~/.ssh/id_rsa.pub user@remote.host:pubkey.txt
ssh user@remote.host
mkdir ~/.ssh
chmod 700 .ssh
cat pubkey.txt >> ~/.ssh/authorized_keys
rm ~/pubkey.txt
chmod 600 ~/.ssh/*
exit

See more here: http://www.mtu.net/~engstrom/ssh-agent.php

Some extra steps should be done:
Start the ssh-agent:
eval `ssh-agent`
ssh-add #Add your private key to the agent’s cache:

Test the connection again

Setup an automated start-agent script:
First, click here for his sssha script. It is a BASH shell script, so if you use a different login shell, you will have to modify it. Once you download it, place it in your ~/.ssh/ directory and add this to your ~/.bashrc configuration script, presumably at or near the end:

# setup ssh-agent, if appropriate
if [ -f “$HOME/.ssh/sssha” ]; then
source $HOME/.ssh/sssha
fi

Finally, if you are truly paranoid, make sure to kill your ssh-agent when you are done using any machine on which you have started one. This can be accomplished most simply with ssh-agent -k.

Note: I personally prefer to add an alias to the .bashhrc profile:
alias ssha=’eval \`ssh-agent\`; ssh-add’

and run it manually when I need it.

Advertisements

Written by youryblog

November 19, 2010 at 10:29 AM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: