Debian系统怎样配置允许root用户远程SSH登录

在全新安装 Debian Linux 系统后,默认情况下 root 用户的 SSH 远程登录是被禁用的。如果您尝试直接使用 root 账户登录 Debian 11 服务器,系统将拒绝访问。要在 Debian Linux 上启用 root 用户 SSH 登录,需要进行 SSH 服务器配置。

1. 安装 SSH 服务器

首先,确保系统已经安装了 OpenSSH 服务器。如果使用的是 WSL 版本的 Ubuntu/Debian,需先卸载现有 SSH 服务器:文章源自堕落的鱼-https://www.duoluodeyu.com/2767.html

apt remove openssh-server

然后,安装 OpenSSH 服务器:文章源自堕落的鱼-https://www.duoluodeyu.com/2767.html

sudo apt install openssh-server

安装完成后,SSH 服务会自动启动。如果未启动,可以手动开启:文章源自堕落的鱼-https://www.duoluodeyu.com/2767.html

systemctl start ssh.service

2. 安装 Vim 编辑器

由于需要修改 SSH 配置文件,建议安装 Vim 作为文本编辑器。先使用普通用户登录 Debian 服务器,然后切换到 root 用户:文章源自堕落的鱼-https://www.duoluodeyu.com/2767.html

su root

接着安装 Vim:文章源自堕落的鱼-https://www.duoluodeyu.com/2767.html

apt-get install vim

3. 修改 SSH 配置文件

使用 Vim 打开 SSH 配置文件:文章源自堕落的鱼-https://www.duoluodeyu.com/2767.html

vim /etc/ssh/sshd_config

找到以下两项,并修改为:文章源自堕落的鱼-https://www.duoluodeyu.com/2767.html

PermitRootLogin yes
PasswordAuthentication yes

文章源自堕落的鱼-https://www.duoluodeyu.com/2767.html

文章源自堕落的鱼-https://www.duoluodeyu.com/2767.html

修改完成后,按 :wq 退出并保存文件。文章源自堕落的鱼-https://www.duoluodeyu.com/2767.html

4. 重启 SSH 服务器

配置完成后,重新启动 SSH 服务器以使更改生效:

/etc/init.d/ssh restart

从现在开始,您可以使用 root 用户通过 SSH 登录 Debian 服务器。建议使用 SecureCRT 或其他 SSH 客户端进行连接测试。

 
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证