话不多说,从不啰嗦,仔细操作,完美一波。
1. 安装更新ssh服务器
sudo apt-get install openssh-server
输入密码
2. 开启ssh服务
sudo service ssh start
3.设置开机自启ssh服务
sudo systemctl enable ssh
切记:上面这行代码是设置自启动的,如果不需要自启动或者是每次想自己连接的话,可以执行下面这行代码关闭
sudo systemctl disable ssh
4.重启检查
reboot
5.检查是否设置成功
sudo systemctl status ssh
结果如下,Active:active(running)即设置成功啦。
ubuntu@ubuntu-virtual-machine:~/桌面$ sudo systemctl status ssh
[sudo] password for ubuntu:
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: e>
Active: active (running) since Sun 2022-07-10 17:42:47 CST; 2min 5s ago
Docs: man:sshd(8)
man:sshd_config(5)
Process: 1532 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 1569 (sshd)
Tasks: 1 (limit: 4588)
Memory: 4.2M
CGroup: /system.slice/ssh.service
└─1569 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups