2

您能否建议一种无需帐户和/或密码即可检测服务器上是否可用 scp 服务的方法?

我想弄清楚如何判断

 Net::SCP->new( "hostname", "username" );

由于远程主机上的服务不可用或由于身份验证失败,函数无法连接到远程。

4

4 回答 4

6

sshd 将在端口 22 上运行。Telnet 到它以查看它是否响应。

要在不编码的情况下检查服务器,请在命令行中键入:

telnet host.example.com 22

如果 ssh 服务可用,响应将如下所示:

Trying host.example.com...
Connected to host.example.com.
Escape character is '^]'.
SSH-2.0-OpenSSH_5.1p1 Debian-5ubuntu1

如果没有,您将看到:

Trying host.example.com...
telnet: Unable to connect to remote host: Connection refused
于 2009-06-12T08:12:43.997 回答
1

Net::SCP doesn't use passwords unless you're using the interactive mode, it uses RSA or DSA keys. At the point you use get() or put(), those functions will return a true or false on success or failure.

You might wish to check out Net::SCP::Expect instead if you need to use passwords instead of key authentication. The perldoc for both modules has good examples to follow.

于 2009-06-12T08:18:42.470 回答
1

使用 Net::SSH2 或 Net::OpenSSH 而不是 Net::SCP

于 2010-08-23T08:28:48.220 回答
0

查德威克在上面是正确的,但是当您认为它应该工作并且 sshd 正在运行时,请检查以下内容:

  1. 路线好吗?尝试

    ping host.example.com
    
  2. host.example.com 上的 hosts.allow 文件是否设置为允许连接?如果您使用 DNS 名称,它必须能够解析传入连接。

  3. host.example.com 上是否运行防火墙?尝试

    iptables -L
    

    在 Linux 上或在 Windows 上检查防火墙。

于 2013-08-14T15:59:03.370 回答