【问题标题】:scp command asks for a passwordscp 命令要求输入密码
【发布时间】:2013-11-24 17:09:22
【问题描述】:

我正在尝试将一些文件从我的服务器下载到我的本地计算机。这是我正在使用的代码:

sudo scp -r servername@xxx.xxx.xx.xx:/root/.tsung/log/20131112-1329/ /home/Desktop/

它会问我三遍密码。但我知道我没有为我的服务器设置密码,但我使用 .pem 文件连接它。如何将 .pem 文件与 scp 命令一起使用?

编辑:我也试过:

scp -i /home/xx/Desktop/xx.pem servername@xxx.xxx.xxx.xxx:/root/.tsung/log/20131112-1329/ /home/besler/Desktop/

仍然要求输入服务器密码。

scp -v /home/besler/Desktop/xx.pem servername@xxx.xxx.xxx.xxx:/root/.tsung/log/20131112-1329//home/besler/Desktop/的结果

Executing: cp '--' '/home/besler/Desktop/beslergokhan.pem' '/home/besler/Desktop/'
cp: `/home/besler/Desktop/beslergokhan.pem' and `/home/besler/Desktop/beslergokhan.pem' are the same file
Executing: program /usr/bin/ssh host xxx.xx.xx.xx, user ubuntu, command scp -v -d -f -- /root/.tsung/log/20131112-1329/
OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to xxx.xx.xx.xx [xxx.xx.xx.xx] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type 2
debug1: Checking blacklist file /usr/share/ssh/blacklist.DSA-1024
debug1: Checking blacklist file /etc/ssh/blacklist.DSA-1024
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 9e:92:5a:57:11:fc:79:de:93:be:6d:1b:28:03:d6:4a
debug1: Host 'xxx.xx.xx.xx' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering DSA public key: /root/.ssh/id_dsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Next authentication method: password
ubuntu@xxx.xx.xx.xx's password: 

【问题讨论】:

  • pem 文件是否与ssh 命令一起使用? (换句话说,您确定它有效吗?)
  • 试试scp -v;它可能会显示正在发生的事情......
  • 你可以看到更新后的帖子,其中包括 scp -v 结果

标签: linux shell ssh scp


【解决方案1】:

您正在使用sudo,它切换到 root 用户执行命令,因此使用安装在 root 的 ssh 配置中的凭据。

【讨论】:

  • 我确实从 sudo 退出并在没有 sudo 和 .pem 文件的情况下运行它。结果如下:警告:未受保护的私钥文件! '/home/besler/Desktop/xx.pem' 的权限 0664 太开放。要求您的私钥文件不能被其他人访问。此私钥将被忽略。
  • 运行chmod 600 /home/besler/Desktop/beslergokhan.pem来保护你的私钥
【解决方案2】:

命令中没有提到 pem 文件的位置。请使用 -i 选项并在命令中提及文件名。

【讨论】:

  • 是的,我刚刚更新了第一篇文章。我也试过了,但仍然要求输入服务器密码。
猜你喜欢
  • 2011-09-10
  • 2022-01-08
  • 2020-10-02
  • 2019-08-25
  • 2013-07-22
  • 1970-01-01
  • 2022-01-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多