#!/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
SSH无密码登录脚本
最新推荐文章于 2022-10-02 09:39:46 发布