记录一下,20.04.1-Ubuntu刚刚装完后的操作
一、修改root密码
初始安装的系统root密码随机,进入系统后需要使用普通用户重置root密码
user@user-virtual-machine:~$ sudo passwd
[sudo] password for user:
New password:
Retype new password:
passwd: password updated successfully
user@user-virtual-machine:~$ su root
Password:
root@user-virtual-machine:/home/user
二、开启ssh
安装过程
root@user-virtual-machine:~/Desktop
root@user-virtual-machine:~/Desktop
root@user-virtual-machine:~/Desktop
root 11073 1 0 23:09 ? 00:00:00 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
root 12409 10616 0 23:10 pts/0 00:00:00 grep --color=auto ssh
root@user-virtual-machine:~
root@user-virtual-machine:~
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3007/sshd: /usr/sbi
tcp6 0 0 :::22
root@user-virtual-machine:~/Desktop
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:89:a7:46 brd ff:ff:ff:ff:ff:ff
altname enp2s1
inet 192.168.163.155/24 brd 192.168.163.255 scope global dynamic noprefixroute ens33
valid_lft 1607sec preferred_lft 1607sec
inet6 fe80::d41a:57c1:e4e6:5172/64 scope link noprefixroute
valid_lft forever preferred_lft forever
为了方便使用netstat指令查看端口
三、ssh服务开启和关闭的指令
root@user-virtual-machine:~/Desktop
或root@user-virtual-machine:~/Desktop
root@user-virtual-machine:~/Desktop
或root@user-virtual-machine:~/Desktop
root@user-virtual-machine:~/Desktop
或root@user-virtual-machine:~/Desktop
或root@user-virtual-machine:~/Desktop
或root@user-virtual-machine:~/Desktop
root@user-virtual-machine:~/Desktop
或root@user-virtual-machine:~/Desktop
root@user-virtual-machine:~/Desktop
或root@user-virtual-machine:~/Desktop
root@user-virtual-machine:~/Desktop
四、问题解决
1、命令行可使用root用户,桌面不能
此处使用的gedit指令,使用vi指令也行
root@user-virtual-machine:~/Desktop# gedit /etc/pam.d/gdm-autologin 注释掉第三行内容 auth required pam_succeed_if.so user != root quiet_success
root@user-virtual-machine:~/Desktop# gedit /etc/pam.d/gdm-password 注释掉第三行内容 auth required pam_succeed_if.so user != root quiet_success
2、ssh端口已通,但是不能远程登录
在sshd_config配置中,设置成允许root登录
root@user-virtual-machine:~/Desktop# gedit /etc/ssh/sshd_config 将第34行的 PermitRootLogin prohibit-password 修改为 PermitRootLogin yes
|