ssh: connect to host xxx.xxx.xxx.xxx port 22: Connection refused

工具/原料:Ubuntussh

 

在采用scp在不一样机器之间进行文件拷贝时出现标题所示的错误,缘由多是:工具

1.sshd 未启动spa

 

2.sshd 未安装rest

3.防火墙code

4需从新启动ssh 服务server

查看sshd进程方式:ps -e | grep ssh,若是相似以下blog

14688 ?        00:00:00 ssh-agent
24647 pts/2    00:00:00 ssh

没有sshd,则说明sshd未启动,尝试启动:进程

service sshd restart(须要root权限)

若是出现:ci

Failed to restart ssh.service: Unit ssh.service not found.

说明sshd未安装,或者经过查看/etc/init.d/目录下是否有ssh,若没有则说明须要安装sshd.get

安装sshd:

sudo apt-get install openssh-server

安装完成后ps -e | grep ssh查看是否启动。

注意:安装完后,查看/etc/ssh/sshd_config中是否有"PermitRootLoginwithout-password“这一项,如有加#注释掉,而后增长一句"PermitRootLogin   yes",保存退出便可。

若是sshd已经安装,且也已经启动,但仍是链接不上,试着重启ssh

service ssh restart

若仍是不行,那就多是防火墙的问题了,关闭防火墙

sudo ufw disable

而后检查是否可以链接成功

ssh localhost

出现

The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:wCcI3OLsC4FcUDhMmuJZ3WLf4uK0BMphJaRkFIo/zqg.
Are you sure you want to continue connecting (yes/no)? 

说明链接成功。

相关文章
相关标签/搜索