2018-10-09 ssh 免密登录以及备份

服务器 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.

image.png

加入schedule

crontab crontab.txt 
crontab -l

设置远程主机别名
vim ~/.ssh/config

Host jhd
HostName 1xx.1xx.1xx.67
User root
IdentitiesOnly yes

其中:

  1. Host 后边的是名称,以后可以根据这个名称进行访问;
  2. HostName是你的主机IP地址;
  3. User为主机登录的用户名;
  4. IdentitiesOnly yes固有配置;
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 专业考题类型管理运行工作负责人一般作业考题内容选项A选项B选项C选项D选项E选项F正确答案 变电单选GYSZ本规程...
    小白兔去钓鱼阅读 13,364评论 0 13
  • 1.埋点是做什么的 2.如何进行埋点 3.埋点方案的设计 近期常被问到这个问题,我担心我的答案会将一些天真烂漫的孩...
    lxg阅读 6,600评论 0 1
  • __ __ |__| _____ __ __ ┌...
    wangchuang2017阅读 11,926评论 2 1
  • 选择题部分 1.(),只有在发生短路事故时或者在负荷电流较大时,变流器中才会有足够的二次电流作为继电保护跳闸之用。...
    skystarwuwei阅读 14,779评论 0 7
  • 4月23日是世界读书日,上网浏览时也就多看了几眼写读书的文章。不管是读书的三境界还是四境界,精彩论述让人觉得很“养...
    曳杖步斜阳阅读 2,635评论 0 1

友情链接更多精彩内容