ssh认证实战

为了实现Centos之间自动从远程机器复制文件到本地,需要做如下配置操作:

认证设置:

1.      本地输入:ssh-keygen -t rsa

2.      输出Generating public/private rsa key pair.【回车】

                Enterfile in which to save the key (/root/.ssh/id_rsa): 【回车】

                   Enterpassphrase (empty for no passphrase): 【回车】

                   Entersame passphrase again: 【回车】

                   Youridentification has been saved in /root/.ssh/id_rsa.

                   Yourpublic key has been saved in /root/.ssh/id_rsa.pub.

                   Thekey fingerprint is:

                   51:96:fd:d4:15:96:ba:11:3a:c3:1a:03:b9:dc:7a:20root@server-main1

                  The key's randomart image is:

                   +--[RSA 2048]----+

                   |        . oo  +=|

                   |       o o. ..o..|

                   |      . = . .oo |

                   |     E + = = o. |

                   |      . S + o o |

                   |       . o  .   |

                   |        .       |

                   |                 |

                   |                 |

                   +-----------------+

         生成黄色标记的2个文件

3.      将/root/.ssh/id_rsa.pub复制到远程机器/root/下

4.      远程机器执行:cat /root/id_rsa.pub > /root/.ssh/authorized_keys

         提醒:如果之前已经存在authorized_keys文件,请将’>’换成追加符’>>’;双机互相认证自行思考。

自动复制:

1.      本地将scp命令写入/home/xxx.sh文档,需要有执行权限(chmod +x /home/xxx.sh)

2.      编辑/etc/crontab文档,加入命令10 08  * * */home/xxx.sh(每天8点10分执行一次)


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值