仅带密码认证的 SCP 不要求我输入密码

Har*_*nen 10 ssh scp

我正在尝试使用 scp 将文件从一台服务器复制到另一台服务器。

在两台服务器上,我都将 ssh 端口配置为 222。两台服务器的 sshd_config 完全相同(没有 RootLogin,启用 PasswordAuthentication)

由于很多原因在这里解释太长,我不能使用密钥身份验证。

当我使用 scp 从服务器 A 复制到服务器 B(登录到 A)时,它可以工作。但是当我从 B 到 A(登录到 B)做同样的事情时它不起作用:我收到一条错误消息“权限被拒绝”并且 scp 不要求我输入密码(尽管启用了密码身份验证)

这是我使用的命令(登录服务器 B):

scp -P 222 -vvv ~/backup/file user@serverA:/home/user/backup
Run Code Online (Sandbox Code Playgroud)

这是输出的最后几行:

debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: password
debug3: start over, passed a different list password
debug3: preferred publickey,keyboard-interactive
debug1: No more authentication methods to try.
user@serverA: Permission denied (password).
Run Code Online (Sandbox Code Playgroud)

为什么 scp 不要求我输入密码,而启用了“密码”(因为它写在第二个“debug1”行中)?

谢谢你。

kas*_*erd 11

最好的解决方案是询问publickey在该服务器上禁用身份验证的人为什么然后去解决这个问题。使用publickey身份验证比密码更方便、更安全。

您的身份验证失败的原因是客户端和服务器上都没有启用身份验证方法。服务器上启用的身份验证方法是:

debug1: Authentications that can continue: password
Run Code Online (Sandbox Code Playgroud)

客户端启用的身份验证方法是:

debug3: preferred publickey,keyboard-interactive
Run Code Online (Sandbox Code Playgroud)

您可以传递-o PreferredAuthentications=passwordscp仅使用password身份验证。

  • 你是我的男人!在服务器 B 上的 ssh_config 中将“UsePasswordAuthentication”设置为“No”。将其更正为“yes”,就可以了。非常感谢。 (3认同)