ubuntu22.04 LTS配置root登录ssh root登录
# Ubuntu系统信息
- 系统在安装的时候已经默认安装了
openssh-server
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
$ uname -a
Linux ubuntu22.04-go 5.15.0-47-generic #51-Ubuntu SMP Thu Aug 11 07:51:15 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 调整sshd配置文件
# 切换到root用户下
$ sudo -i
$ echo "xxxxx" |passwd --stdin root # 给root用户设置密码
# 编辑sshd的配置
$ vim cat /etc/ssh/sshd_config
PasswordAuthentication yes
PermitRootLogin yes
# 重启sshd服务
$ systemctl restart sshd
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
- 接下来使用客户端工具连接即可
# 未安装openssh-server服务的配置方法
# 切换到root用户下
$ sudo -i
$ echo "xxxxx" |passwd --stdin root # 给root用户设置密码
1
2
3
2
3
# 修改配置
# 01.增加配置条目`greeter-show-manual-login= true`
$ sudo vim greeter-show-manual-login= true
greeter-show-manual-login= true
[Seat:*]
user-session=ubuntu
# 02.注释配置内容`auth required pam_succeed_if.so user != root quiet_success`
$ sudo vim /etc/pam.d/gdm-autologin
#%PAM-1.0
auth requisite pam_nologin.so
#auth required pam_succeed_if.so user != root quiet_success
auth optional pam_gdm.so
auth optional pam_gnome_keyring.so
auth requited pam_permit.so
@include common-account
# SELinux needs to be the first session rule.This ensures that any
# 03.注释配置内容`auth required pam_succeed_if.so user != root quiet_success`
$ sudo vim /etc/pam.d/gdm-password
#%PAM-1.0
auth requisite pam_nologin.so
#auth required pam_succeed_if.so user != root quiet_success
@include common-auth
auth optional pam_gnome_keyring.so
@include common-account
# SELinux needs to be the first session rule.This ensures that any
# lingerling context has been cleared.Without this it is possible
# 04.修改
$ sudo vim /root/.profile
# ~/.profile: executed by Bourne-compatible login shells.
if [ "$BASH" ]; then
if [ -f ~/.bashrc ];then
. ~/.bashrc
fi
fi
tty -s && mesg n || true
mesg n || true
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 安装SSH
# 安装openssh-server
$ sudo apt-get install openssh-server
# 修改配置文件
$ sudo vim /etc/ssh/sshd_config
PermitRootLogin yes # 在#PermitRootLogin prohibit-password的下面,增加一句
# 重启ssh服务
$ systemctl restart sshd
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
上次更新: 2025/07/26, 23:30:02
- 01
- kubernetes部署minio对象存储01-18
- 02
- Jenkins-Argocd CICD-下01-17
- 03
- Jenkins-Argocd CICD Rollouts金丝雀发布优化01-17