Remote Backup and SSH Login without Password • Russwurm

Remote Backup and SSH Login without Password

Created: | Updated:

This is pretty useful if running remote backups within a cron job. The original posting can be found at GeekStuff:3 steps to perform SSH login without password

Step 1: Server Create public and private keys using ssh-key-gen on the server and adding this key to the authorized keys.
$ cd .ssh # if existing
ssh-keygen -t rsa # hit return through all prompts
cat id_rsa.pub >> authorized_keys
chmod 600 authorized_keys
Step 2(Linux): Client Copy the key to the client:
cd .ssh
scp myserver.com:.ssh/id_rsa myserver.rsa
chmod 600 myserver.rsa
echo "Host myserver" >> config
echo "Hostname example.com" >> config
echo "IdentityFile ~/.ssh/myserver.rsa" >> config
Step 2 (Apple): Client Copy the key to the client and add it to the key chain
scp myserver.com:.ssh/id_rsa myserver.rsa
ssh-add -K /<folder>/myserver.rsa
Step 3: Login to remote-host without entering the password
ssh <remote-host>

mysqldump without password

This is done by creating the file ~/.my.cnf in your user directory. The permissions need to be set to 600. Add this to your .my.cnf file
[mysqldump]
user=xxx
password=yyy

Some updates for later

https://www.liberiangeek.net/2014/11/change-openssh-port-centos-7/ https://www.unixmen.com/iptables-vs-firewalld/ https://wiki.centos.org/HowTos/Network/SecuringSSH