SSH配置规范
- 使用公钥进行登录
- 防火墙设置许可IP
- 权限最小化原则
SSH服务安装
安装ssh服务
sudo apt-get update
sudo apt-get install ssh
修改sshd_config配置
sOldPasswordAuthentication="#PasswordAuthentication no"
sNewPasswordAuthentication="PasswordAuthentication yes"
sOldPermitRootLogin="#PermitRootLogin prohibit-password"
sNewPermitRootLogin="PermitRootLogin yes"
sed -i "s/${sOldPasswordAuthentication}/${sNewPasswordAuthentication}"/g /etc/ssh/sshd_config
sed -i "s/${sOldPermitRootLogin}/${sNewPermitRootLogin}"/g /etc/ssh/sshd_config
启动ssh服务
/etc//ssh start
service ssh start
验证ssh服务状态
/etc//sshd status
设置开机自启
ssh enable