VMware Workstation 安装 Debian 8,发现 SFTP、SCP 模式登陆权限只在普通账户,而 Putty 可以通过提权到 root,FTP 始终无法删改任何文件,所以要打开 root 登陆。
解决
快速修改
# 允许 root 登录
sed -ri 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -ri 's/PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -ri 's/#PermitRootLogin without-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -ri 's/PermitRootLogin without-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -ri 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config
# 允许密码验证
sed -ri 's/#PasswordAuthentication yes/PasswordAuthentication yes/g' /etc/ssh/sshd_config
sed -ri 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
# 允许空密码登录(可选)
sed -ri 's/PermitEmptyPasswords no/PermitEmptyPasswords yes/g' /etc/ssh/sshd_config
可选 pam 修改
sed -ri 's/session required pam_loginuid.so/#session required pam_loginuid.so/g' /etc/pam.d/sshd
重启 ssh
/etc/init.d/ssh restart
如果重启后还不能使用 root 登录,普通用户登录后执行:
# 执行后输入密码切换到 root
sudo -i
# 重设 root 密码即可
passwd
更新 2016-09-15