Password-less authentication:
- generate public and private key e.g. with
ssh-keygen -a 100 -t ed25519 -C "a comment" -f name_of_the_file
note: previously ssh-keygen -t rsa -b 4096 -C "a comment"
- on the machine from which you connect: put private key in
~/.ssh/id_rsa
(for rss key) or ~/.ssh/id_dsa
(for dsa key), with 0600 permissions
- on the machine you connect to: append public key to
~/.ssh/authorized_keys
(also with 0600 permission)
Using ssh agent:
Ssh agent remembers password for your private key, so you only have to type it once in a session, not every time it’s used.
Start ssh agent: ssh-agent
Add keys: ssh-add
List currently loaded keys: ssh-add -l
Cygwin and ssh agent:
Links:
Add this to ~/.bashrc
:
## Enable ssh agent
export SSH_AUTH_SOCK=/tmp/.ssh-socket
ssh-add -l \>/dev/null 2\>&1
if [ $? = 2 ]; then
# Exit status 2 means couldn’t connect to ssh-agent; start one now
rm -rf /tmp/.ssh*
ssh-agent -a $SSH_AUTH_SOCK >/tmp/.ssh-script
. /tmp/.ssh-script
echo $SSH_AGENT_PID >/tmp/.ssh-agent-pid
fi
function kill-agent {
pid=`cat /tmp/.ssh-agent-pid`
kill $pid
}
function addkeys {
ssh-add ~/.ssh/id_dsa*
}
Set an alias for a hostname
In ~/.ssh/config
:
Host dev30
HostName dev30.kowalczyk.info
User root
IdentityFile ~/.ssh/id_dsa_dev30