Debian切换Root用户SSH远程登录及设置主机名




 

Debian切换Root用户SSH远程登录

Debian默认是不允许root用户登录,更不允许SSH登录,修改方法如下:

打开终端,用普通用户登录

在终端输入: su - 然后输入密码,切换到root用户

  1. [root@Debian ~]# su -
  2. Password: # 此处输入您的密码
  3. [root@Debian ~]#

设置root用户登录

修改sshd配置文件

  1. [root@Debian ~]# vi /etc/ssh/sshd_config

修改配置

查找PermitRootLogin,在"#PermitRootLogin prohibit-password"下面添加"PermitRootLogin yes",同时,查找"PasswordAuthentication",把"PasswordAuthentication yes"前面的注释“#”删除。

  1. [root@Debian ~]# vi /etc/ssh/sshd_config
  2. #PermitRootLogin prohibit-password
  3. PermitRootLogin yes
  4. …………
  5. PasswordAuthentication yes

重启SSH服务

命令行输入以下任意一条命令即可

  1. [root@Debian ~]# /etc/init.d/ssh restart
  2. [root@Debian ~]# systemctl restart sshd
  3. [root@Debian ~]# service sshd restart

Debian设置主机名

查看当前主机名

要查看当前主机名,请运行hostnamectl命令。在此示例中,当前主机名设置为localhost.localdomain。

  1. [root@Debian ~]# hostnamectl
  1. Static hostname: Debian
  2. Icon name: computer-vm
  3. Chassis: vm
  4. Machine ID: 032aab5f4da64fd789b0c302645ce586
  5. Boot ID: 15ebaf588922460ea8d41f983eb2844a
  6. Virtualization: vmware
  7. Operating System: Debian GNU/Linux 11 (bullseye)
  8. Kernel: Linux 5.10.0-18-amd64
  9. Architecture: x86-64

hostnamect设置主机名

可以使用hostnamectl命令更改系统主机名。这是hostnamectl命令的语法hostnamectl set-hostname host.example.com。例如,要将系统静态主机名更改为host.debian.com,可以运行命令hostnamectl set-hostname host.debian.com。

  1. [root@Debian ~]# hostnamectl set-hostname host.debian.com

评论

此博客中的热门博文

纯IPV6 VPS安装hysteria、x-ui面板,并实现多VPS轮换

CentOS7修改默认SSH端口

纯IPV6服务器(Euserv)安装哪吒面板