![Netcat 可以工作,但 SSH 不工作](https://linux22.com/image/686106/Netcat%20%E5%8F%AF%E4%BB%A5%E5%B7%A5%E4%BD%9C%EF%BC%8C%E4%BD%86%20SSH%20%E4%B8%8D%E5%B7%A5%E4%BD%9C.png)
我正在尝试连接到我的 ssh 服务器。当我这样做时,我收到常见的错误:
Could not resolve hostname x.x.x.x:22: Name or service not known
但是当我跑步时nc -v x.x.x.x 22
我得到:
Connection to x.x.x.x 22 port [tcp/ssh] succeeded!
SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu1
我不确定下一步该如何解决这个问题。有什么想法吗?
答案1
您没有显示通过 SSH 连接时使用的命令
看起来你这样做了
$ ssh 192.168.1.1:22
ssh: Could not resolve hostname 192.168.1.1:22: Name or service not known
语法如下
ssh ip -p port
例子
$ ssh 192.168.1.1 -p 22
The authenticity of host '192.168.1.1 (192.168.1.1)' can't be established.
RSA key fingerprint is SHA256:fPvLlf+BPZHq47Y1GF67YofaAn1jYLElis0.
Are you sure you want to continue connecting (yes/no)?
不过,端口 22 是默认的 SSH 端口,您根本不需要指定它。