To configure ssh from SOURCE to DESTINATION
1. On SOURCE and DESTINATION execute the following command
mkdir ~/.ssh;chmod 700 ~/.ssh.
If the directory already exists then ignore the error message
2. On SOURCE execute the following command to create private and public key
ssh-keygen -t rsa -b 2048
3. Execute the following commands on SOURCE
eval `ssh-agent`;ssh-add ~/.ssh/id_rsa;ssh-add -l
4. On SOURCE add the following code to file ~/.bashrc
SSH_ENV=$HOME/.ssh/environment
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV}
echo succeeded
chmod 600 ${SSH_ENV}
. ${SSH_ENV} > /dev/null
/usr/bin/ssh-add;
}
# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
. ${SSH_ENV} > /dev/null
ps ax | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi
5. On SOURCE and execute
scp ~/.ssh/id_rsa.pub DESTINATION:~/.ssh/authorized_keys2
Enter password at the prompt
scp ~/.ssh/id_rsa.pub DESTINATION:~/.ssh/authorized_keys2
Enter password at the prompt
Go to DESTINATION and check if file authorized_keys2 is present
6. Go to SOURCE and execute
eval `ssh-agent`;ssh-add ~/.ssh/id_rsa;ssh-add -l
source ~/.bashrc
No comments:
Post a Comment