LINUX用户建立秘钥认证实现SHELL脚本管理、分发和部署
副标题[/!--empirenews.page--] 环境: ssh server: 192.168.100.29 server.example.com ssh client: 192.168.100.30 client.example.com 通过root用户建立秘钥认证实现SHELL脚本管理,分发,部署 首先client端创建秘钥对,并将公钥分发给需要登录的SSH服务端 注:公钥相当于锁,私钥相当于钥匙,我们这里相当于在客户端创建一对钥匙和锁,想要做到SSH免密码登录,就相当于我们将锁分发到服务端并装锁,然后客户端就可以利用钥匙开锁。 一.建立秘钥认证 1.在客户端创建秘钥对:(ssh client) # su - root # ssh-keygen -t dsa 一路回车即可 ---------------------- Generating public/private dsa key pair. Enter file in which to save the key (/root/.ssh/id_dsa): Created directory '/root/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_dsa. Your public key has been saved in /root/.ssh/id_dsa.pub. The key fingerprint is: e9:5e:4a:7f:79:64:c5:ae:f2:06:a7:26:e4:41:5c:0e root@zabbix.example.com The key's randomart image is: +--[ DSA 1024]----+ | | | E . | | . + . | | .o . o| | S. o | | . o . + .| | oo.. B . | | o +o * + | | o .+ =. | +-----------------+ ---------------------- 2.查看生成的秘钥对:(ssh client) # ls -lda .ssh ----------------- drwx------ 2 root root 4096 6月 6 23:03 .ssh ----------------- # cd .ssh # ls -la ------------------ 总用量 16 drwx------ 2 root root 4096 6月 6 23:03 . dr-xr-x---. 26 root root 4096 6月 6 23:03 .. -rw------- 1 root root 668 6月 6 23:03 id_dsa -rw-r--r-- 1 root root 613 6月 6 23:03 id_dsa.pub ------------------ 秘钥生成完毕 (编辑:佛山站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |