您的位置:首页 > 其它

SSH无密码登录脚本

2014-05-06 11:26 260 查看
#!/bin/bash
file="/root/.ssh/authorized_keys"
sed -i "s/#PubkeyAuthentication/PubkeyAuthentication/g" /etc/ssh/sshd_config
sed -i "s/#AuthorizedKeysFile/AuthorizedKeysFile/g" /etc/ssh/sshd_config
sed -i "s/#ListenAddress 0.0.0.0/ListenAddress 0.0.0.0/g" /etc/ssh/sshd_config
sed -i "s/#UseDNS yes/UseDNS no/g" /etc/ssh/sshd_config
sed -i "s/GSSAPIAuthentication no/GSSAPIAuthentication yes/g" /etc/ssh/sshd_config
if [ ! -d "/root/.ssh" ];then
mkdir -p /root/.ssh
fi
if [ ! -f $file ];then
\cp authorized_keys /root/.ssh
else
cat authorized_keys >> $file
fi
chmod 600 /root/.ssh/authorized_keys
service sshd restart
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: