ubuntu配置ssh登录

环境:
Os:18.04.1

1.查看当前ssh是否运行

 

2.安装ssh(没有运行的情况下需要安装)
sudo apt-get update
sudo apt-get install openssh-server

root@oracle-VirtualBox:~# ps -e|grep ssh
1405 ? 00:00:00 ssh-agent
4060 ? 00:00:00 sshd
5143 ? 00:00:00 sshd
5213 ? 00:00:00 sshd

 

3.查看服务

root@oracle-VirtualBox:~# systemctl status sshd
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2024-07-01 15:28:15 CST; 1min 35s ago
 Main PID: 4060 (sshd)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/ssh.service
           └─4060 /usr/sbin/sshd -D

7月 01 15:28:15 oracle-VirtualBox systemd[1]: Starting OpenBSD Secure Shell server...
7月 01 15:28:15 oracle-VirtualBox sshd[4060]: Server listening on 0.0.0.0 port 22.
7月 01 15:28:15 oracle-VirtualBox sshd[4060]: Server listening on :: port 22.
7月 01 15:28:15 oracle-VirtualBox systemd[1]: Started OpenBSD Secure Shell server.
7月 01 15:28:29 oracle-VirtualBox sshd[5143]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=
7月 01 15:28:30 oracle-VirtualBox sshd[5143]: Failed password for oracle from 192.168.1.102 port 54703 ssh2
7月 01 15:28:37 oracle-VirtualBox sshd[5143]: Accepted password for oracle from 192.168.1.102 port 54703 ssh2
7月 01 15:28:37 oracle-VirtualBox sshd[5143]: pam_unix(sshd:session): session opened for user oracle by (uid=0)
lines 1-16/16 (END)

 

4.安装vi
下面需要使用vi进行编辑
oracle@oracle-VirtualBox:~$ sudo apt install vim

 

5.配置root可以ssh登录
sudo vi /etc/ssh/sshd_config

修改如下项目,没有该项的话在文件最后面添加

PermitRootLogin yes

16.04版本需要将如下行注释掉

#PermitRootLogin prohibit-password

 

重启sshd
sudo systemctl restart sshd

posted @ 2024-07-01 15:40  slnngk  阅读(40)  评论(0编辑  收藏  举报