diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..4870e3c Binary files /dev/null and b/.DS_Store differ diff --git a/笔记/开启root远程登录Linux-permitrootlogin.md b/笔记/开启root远程登录Linux-permitrootlogin.md index 8a1d208..240c980 100644 --- a/笔记/开启root远程登录Linux-permitrootlogin.md +++ b/笔记/开启root远程登录Linux-permitrootlogin.md @@ -1,30 +1,31 @@ ---- -title: 开启root远程登录Linux -date: 2021-04-14 11:38:32.0 -updated: 2022-09-13 09:40:06.804 -url: /archives/permitrootlogin -categories: -- Linux -tags: -- Linux ---- ++++ +title = 'Linux启用root远程登录' +date = 2024-02-02T10:47:18+08:00 +draft = false -设置root密码 -``` -sudo passwd -``` -修改配置文件**sshd_config** -``` -sudo vim /etc/ssh/sshd_config -``` ++++ + +在Linux系统中,要启用远程登录root并允许使用密码登录,需要编辑SSH服务器的配置文件 /etc/ssh/sshd_config。 + +以下是步骤: + +1. 使用具有足够权限的用户(如sudo用户)通过SSH或终端登录到Linux服务器。 + +2. 打开SSH配置文件: + + ```sh + sudo nano /etc/ssh/sshd_config + ``` + +3. 修改以下配置项:允许root用户远程登录:将 PermitRootLogin 行改为 PermitRootLogin yes 或者 PermitRootLogin without-password (如果你打算使用密钥对验证而不是密码)。 注意:出于安全考虑,强烈建议使用公钥认证而非密码认证。如果禁用了密码登录,且希望重新启用密码登录,确保没有 PasswordAuthentication no 这一行或者将其注释掉,或者改为 PasswordAuthentication yes。 + +4. 保存并关闭配置文件: 在nano编辑器中,按 Ctrl+X 然后按 Y 再按 Enter 来保存更改。 + +5. 重启SSH服务以应用新的配置: + + ```sh + sudo systemctl restart sshd + ``` + +6. 测试远程连接: 使用一个支持SSH的客户端尝试以root用户身份远程登录,并输入root用户的密码。请务必注意,允许root用户直接远程登录并通过密码验证是一项安全隐患,通常不推荐在生产环境中这样做。更安全的做法是使用公钥认证结合sudo或其他权限管理机制。 -修改这两条并保存 -``` -PermitRootLogin yes -PasswordAuthentication yes -``` -重载sshd -``` -sudo systemctl reload sshd -``` -重新连接即可使用root权限远程连接 \ No newline at end of file