修改甲骨文免费主机 SSH 的登陆方式,用 ROOT 密码直接登陆
甲骨文免费 VPS 在开机成功后,默认只能使用密钥文件进行登录,其实这也是最安全的做法。但是对于安全要求不高的测试服务器,如果需要在多台终端上进行管理,不方便频繁的 copy 密钥文件,直接打开 root 的 ssh 密码访问权限,也是一种方法。
1、首先我们用密钥文件登陆VPS,甲骨文 Centos 系统默认用户是:opc ,具体可参考《Windows 中 SSH 证书的 Permissions are too open 问题 》。
2、SSH root用户密码访问权限的打开方法
# 切换为 root 用户
sudo -i
# 为 root 用户创建密码,输入两次
passwd
# 修改 /etc/ssh/sshd_config 文件
sed -i "s/#PermitRootLogin yes/PermitRootLogin yes/g" /etc/ssh/sshd_config
sed -i "s/PasswordAuthentication no/PasswordAuthentication yes/g" /etc/ssh/sshd_config
# 重启 ssh 服务
systemctl restart sshd3、做完以上的步骤,ssh 就可以使用密码方式登录了。
4、以上方法在 ubuntu 操作系统上存在问题,究其原因为 ubuntu 操作系统中的 /etc/ssh/sshd_config 文件在 12 行 Include /etc/ssh/sshd_config.d/*.conf 文件。
......
# The strategy used for options in the default sshd_config shipped with
8 # OpenSSH is to specify options with their default value where
9 # possible, but leave them commented. Uncommented options override the
10 # default value.
11
12 Include /etc/ssh/sshd_config.d/*.conf
13
14 #Port 22
15 #AddressFamily any
16 #ListenAddress 0.0.0.0
17 #ListenAddress ::
......而 /etc/ssh/sshd_config.d/ 目录中的 .conf 文件,包含如下行:
PasswordAuthentication no解决办法直接注释 /etc/ssh/sshd_config 中 12 行,然后在 /etc/ssh/sshd_config 文件中增加
PermitRootLogin yes
PasswordAuthentication yes或者将 /etc/ssh/sshd_config.d/ 目录中的 .conf 文件修改为
#PasswordAuthentication no
PermitRootLogin yes
PasswordAuthentication yes本文作者:ifeng
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0(在新窗口打开)
许可协议。转载请注明出处!