localhost: ssh: connect to host localhost port 22: Connection refused.
- 安装openssh-server:
1 | $ sudo apt-get install openssh-server |
- 启动sshd服务
1
$ sudo service start sshd
- 关闭防火墙,或允许防火墙开放22端口
1
2
3
4
5# 关闭
$ sudo ufw disable
# 允许开放22端口
$ sudo ufw allow 22 - 检查:
1
2
3
4
5
6$ ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:QjfgDMQrMms2YyootfWGBh5rFOWAgTxRHxDyRedmTTg.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
jack@localhost's password:
可以看到,我连自己的机器还需要输入密码,显然不友好,使用ssh-key解决:
1 | # 1.生成ssh key |