批量添加公钥给server的bash
Posted OS Knowledge Base
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了批量添加公钥给server的bash相关的知识,希望对你有一定的参考价值。
Bash 脚本
#/bin/bash adduser vlmonitor mkdir -p /home/vlmonitor/.ssh chown -R vlmonitor.vlmonitor /home/vlmonitor/.ssh/ chmod -R 700 /home/vlmonitor/.ssh/ echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD5eLJ917WlMCA+EpOESXmCOv1v6+2uMSgT6q/3WSfARUwEsWisKdPGOGYCZgeHA/i3yoLha5ei0AAAAB3NzaC1yc2EAAAADAQABAAABAQD5eLJ917WlMCA+EpOESXmCOv1v6+2uMSgT6q/3WSfARUwEsWisKdPGOGYCZgeHA/i3yoLha5ei0LAAAAB3NzaC1yc2EAAAADAQABAAABAQD5eLJ917WlMCA+EpOESXmCOv1v6+2uMSgT6q/3WSfARUwEsWisKdPGOGYCZgeHA/i3yoLha5ei0 [email protected]" > /home/vlmonitor/.ssh/authorized_keys chown -R vlmonitor.vlmonitor /home/vlmonitor/.ssh/authorized_keys chmod 600 /home/vlmonitor/.ssh/authorized_keys
注意:采用公私钥的方式登陆ssh的方法,对配置文件和目录的权限及其敏感,700,600的问题要搞清楚
以上是关于批量添加公钥给server的bash的主要内容,如果未能解决你的问题,请参考以下文章
shell脚本实现ssh-copy-id批量自动发送公钥到远程主机
使用实体框架迁移时 SQL Server 连接抛出异常 - 添加代码片段