xuke123 发表于 2018-8-27 07:11:14

自动配置ssh服务shell脚本

#!/bin/bash  
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
  
read -p "Port(22):" port
  
sed -i "13c Port ${port}" /etc/ssh/sshd_config
  
read -p "LoginGraceTime(s/m/h):" LoginGraceTime
  
sed -i "41c LoginGraceTime ${LoginGraceTime}" /etc/ssh/sshd_config
  
read -p "PermitRootLogin(yes/no):" PermitRootLogin
  
sed -i "42c PermitRootLogin ${PermitRootLogin}" /etc/ssh/sshd_config
  
read -p "UseDNS(yes/no):" UseDNS
  
sed -i "122c UseDNS ${UseDNS}" /etc/ssh/sshd_config
  
read -p "PrintMotd(yes/no):" PrintMotd
  
case $PrintMotd in
  
yes)
  
sed -i "112c PrintMotd ${PrintMotd}" /etc/ssh/sshd_config
  
read -p "Prompt message:" message
  
echo "${message}" > /etc/motd
  
;;
  
no)
  
sed -i "112c PrintMotd ${PrintMotd}" /etc/ssh/sshd_config
  
;;
  
esac
  
/etc/init.d/sshd restart &>>/dev/null


页: [1]
查看完整版本: 自动配置ssh服务shell脚本