ssh key

Generate key pair

with default names ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub. For security reasons highly recomended to use only passphrase protected keys.

ssh-keygen

 change passphrase of default key if needed

ssh-keygen -p

copy to servers ( if password login allowed)

ssh-copy-id login@servername 

generate public key from existing private

ssh-keygen -y -f ~/.ssh/rsa_id > ~/.ssh/rsa_id.pub


ssh-agent

ssh-agent autostart

.bashrc
AGENT=`ps -ef |grep ssh-agent|grep $USER|grep -v grep`
if [ "${AGENT}" = "" ];
then
 ssh-agent > .ssh/agent_env
 source .ssh/agent_env
else
 source .ssh/agent_env
fi

KEYLIST=`ssh-add -l`
if [ "${KEYLIST}" = "The agent has no identities." ];
then
 ssh-add
fi

enable passwords

sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
service sshd restart
  • No labels