结合sshpass实现ssh单向免密钥通信

文章目录

    • 1.1 我的环境和我的需求
    • 1.2 A服务器的chenliang用户下生成[密钥对]
    • 1.3 A服务器上将chenliang用户的公钥至B、C服务器的chenliang用户下

1.1 我的环境和我的需求

我的服务器

我的需求

1.2 A服务器的chenliang用户下生成[密钥对]

注意:是在A服务器的chenliang用户下操作

创建相关的目录

编写生成密钥对的脚本 01.create-key-pair.sh

执行生成密钥对的脚本 01.create-key-pair.sh

1.3 A服务器上将chenliang用户的公钥至B、C服务器的chenliang用户下

A服务器上安装sshpass工具 注意:在具备安装软件权限的用户下执行,例如:root

准备hostip.txt文件,后面的脚本02.sshpass-cp-publickey-to-target-host.sh会用到 在chenliang用户下执行

**编写公钥拷贝的脚本:02.sshpass-cp-publickey-to-target-host.sh **注意:是在chenliang用户下操作,脚本中有些变量要更改的哈

执行公钥拷贝脚本:02.sshpass-cp-publickey-to-target-host.sh

A服务器上的chenliang用户远程连接B、C服务器上的chenliang用户

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2022年11月27日
下一篇 2023年1月1日

相关推荐