服务器 A
ssh-keygen -t rsa
# generate id_rsa.pub, copy it to server B
服务器 B,
mv id_rsa.pub ~/.ssh/authorized_keys
# 如果有多个服务器连接 cat id_rsa.pub >> ~/.ssh/authorized_keys
# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh/
chmod 600 ~/.ssh/authorized_keys
这样 服务器 A就可以免密登录服务器B
ssh nong@222.200.186.169
反之亦然~
备份, rsync 进行备份, crontab 定时执行
vim /data2/nong/bak_161/crontab.txt
0 2 * * * rsync -av -l -e ssh nong@222.200.186.161:/public/home/nong/webs/ /data2/nong/bak_161/webs
0 2 * * * rsync -av -l -e ssh nong@222.200.186.161:/public/home/nong/pipeline /data2/nong/bak_161/pipeline
0 2 * * * rsync -av -l -e ssh nong@222.200.186.161:/public/home/nong/python /data2/nong/bak_161/python
- -l, --links copy symlinks as symlinks
The first part is "0 2 * * *". This is where we schedule the timer.
The rest of the line is the command as it would run from the command line.
加入schedule
crontab crontab.txt
crontab -l
设置远程主机别名
vim ~/.ssh/config
Host jhd
HostName 1xx.1xx.1xx.67
User root
IdentitiesOnly yes
其中:
- Host 后边的是名称,以后可以根据这个名称进行访问;
- HostName是你的主机IP地址;
- User为主机登录的用户名;
- IdentitiesOnly yes固有配置;
网友评论