Step 1: Generate RSA Key
# Command to generate rsa key for Ubuntu Linux
ssh-keygen -t rsa -b 2048
There are 2 questions:
a. Enter file in which to save the key => press [enter] key to accept default ~/.ssh
b. Enter passphrase => create a password to access rsa key (recommended)
Step 2: Configure SSH Agent
a. Add SSH Key to ssh-agent
$ eval "$(ssh-agent -s)"
Agent pid 95765
b. Setup Bash to Load ssh-agent
# These lines are meant to generate a $HOME/.bashrc file
# Escape characters are added - please remove those if commands are to be extracted
# Add this to ~/.bash_profile on OSX/Linux or ~/.bashrc on Ubuntu
cat<< EOF > ~/.bashrc
#OR APPEND: cat<< EOF >> ~/.bashrc
echo "Loading ~/.bashrc ..."
SSH_ENV="/home/kim/.ssh/agent-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;
echo "Key loaded: "
/usr/bin/ssh-add -L;
}
# Source SSH settings, if applicable
#i=$(ps -eaf | grep -i ssh-agent |sed '/^$/d' | wc -l | bc -l) # check for service and cast output as integer
#if [ $i > 1 ]; then
# echo "loading ssh key from its default location..."
# /usr/bin/ssh-add;
if [ -f "\${SSH_ENV}" ]; then
. "\${SSH_ENV}" > /dev/null
ps -ef | grep \${SSH_AGENT_PID} | grep ssh-agent\$ > /dev/null || {
start_agent;
}
else
start_agent;
fi
EOF
c. Alternative client: how to Configure Putty’s Pageant
Run pageant.exe (if it’s not already started) > Click Add Key > select the correct PPK > Input key file password if required > OK > Close
If using mRemoteNG, go to Tools > External Tools > Configure pageant to automatically load the correct PPK as shown
Categories: