1. 程式人生 > >批量添加公鑰給server的bash

批量添加公鑰給server的bash

add 公鑰 style 權限 mkdir AS 文件和目錄 mon ech

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 vlmonitor@ip-10-10-1-35
" > /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