Debian切换Root用户SSH远程登录及设置主机名
Debian切换Root用户SSH远程登录
Debian默认是不允许root用户登录,更不允许SSH登录,修改方法如下:
打开终端,用普通用户登录
在终端输入: su - 然后输入密码,切换到root用户
[root@Debian ~]# su -
Password: # 此处输入您的密码
[root@Debian ~]#
设置root用户登录
修改sshd配置文件
[root@Debian ~]# vi /etc/ssh/sshd_config
修改配置
查找PermitRootLogin,在"#PermitRootLogin prohibit-password"下面添加"PermitRootLogin yes",同时,查找"PasswordAuthentication",把"PasswordAuthentication yes"前面的注释“#”删除。
[root@Debian ~]# vi /etc/ssh/sshd_config
#PermitRootLogin prohibit-password
PermitRootLogin yes
…………
PasswordAuthentication yes
重启SSH服务
命令行输入以下任意一条命令即可
[root@Debian ~]# /etc/init.d/ssh restart
[root@Debian ~]# systemctl restart sshd
[root@Debian ~]# service sshd restart
Debian设置主机名
查看当前主机名
要查看当前主机名,请运行hostnamectl命令。在此示例中,当前主机名设置为localhost.localdomain。
[root@Debian ~]# hostnamectl
Static hostname: Debian
Icon name: computer-vm
Chassis: vm
Machine ID: 032aab5f4da64fd789b0c302645ce586
Boot ID: 15ebaf588922460ea8d41f983eb2844a
Virtualization: vmware
Operating System: Debian GNU/Linux 11 (bullseye)
Kernel: Linux 5.10.0-18-amd64
Architecture: x86-64
hostnamect设置主机名
可以使用hostnamectl命令更改系统主机名。这是hostnamectl命令的语法hostnamectl set-hostname host.example.com。例如,要将系统静态主机名更改为host.debian.com,可以运行命令hostnamectl set-hostname host.debian.com。
[root@Debian ~]# hostnamectl set-hostname host.debian.com
评论
发表评论