> 技术文档 > Ubuntu24.04 安装ssh开启22端口及允许root用户远程登录_ubuntu24.04 ssh

Ubuntu24.04 安装ssh开启22端口及允许root用户远程登录_ubuntu24.04 ssh

1、安装openssh-server插件开启22端口访问

# 安装ssh会默认启动服务并开启22端口apt updateapt install openssh-server

 2、开启root用户远程访问

  • 激活root用户,设置root用户登录密码
hunter@localhost:/$ sudo passwd rootNew password: Retype new password: 
  •  修改配置

找到配置文件/etc/ssh/sshd_config,打开注释 #PermitRootLogin prohibit-password,并修改为

PermitRootLogin yes

hunter@hunter-SER:/$ cat /etc/ssh/sshd_config......#LoginGraceTime 2m#PermitRootLogin prohibit-passwordPermitRootLogin yes#StrictModes yes#MaxAuthTries 6#MaxSessions 10......

3、重启 ssh 服务

service ssh restart