启动 SSH 服务
ubuntu 缺省安装了 openssh-client,因此只需要直接安装 openssh-serversudo apt-get install openssh-server安装 openssh-server
lychie@ubuntu:/$ sudo apt-get install openssh-server
[sudo] password for lychie: ******
. . . . . .
Do you want to continue? [Y/n] y
[sudo] password for lychie: ******
. . . . . .
Do you want to continue? [Y/n] y
ps -e | grep ssh若能看到 sshd,说明 ssh-server 已经启动
lychie@ubuntu:/$ ps -e | grep ssh
2089 ? 00:00:00 ssh-agent
5348 ? 00:00:00 sshd
2089 ? 00:00:00 ssh-agent
5348 ? 00:00:00 sshd
连接 SSH 主机
sudo ufw status检查防火墙的状态,若防火墙已开启(active),需打开 22 端口
lychie@ubuntu:/$ sudo ufw status
[sudo] password for lychie: ******
Status: active
[sudo] password for lychie: ******
Status: active
sudo ufw allow 22打开 22 端口
lychie@ubuntu:/$ sudo ufw allow 22
Rule added
Rule added (v6)
lychie@ubuntu:/$ sudo ufw status
Status: active
To Action From
-- ------ ----
22 ALLOW Anywhere
22 (v6) ALLOW Anywhere (v6)
再次连接就可以连的上了Rule added
Rule added (v6)
lychie@ubuntu:/$ sudo ufw status
Status: active
To Action From
-- ------ ----
22 ALLOW Anywhere
22 (v6) ALLOW Anywhere (v6)