【问题标题】:Why ssh connect by -i flag and not with -F flag?为什么 ssh 通过 -i 标志而不是 -F 标志连接?
【发布时间】:2019-08-30 21:05:51
【问题描述】:

我使用的是 Ubuntu 16.04。

我想通过单独的配置文件与亚马逊服务建立 ssh 连接。

我还需要将文件从一台服务器传输到另一台服务器,this post 建议使用单独的配置文件。

当我使用它时它被连接

ssh -i ~/Desktop/ssh_keys/prod.pem ec2-user@***.***.***.***

但当我使用单独的配置时不会:

ssh -F ~/Desktop/ssh_keys/scp_config prod

scp_config

Host prod
    HostName ***.***.***.***
    User ec2-user
    CertificateFile ~/Desktop/ssh_keys/prod.pem

调试信息

OpenSSH_7.2p2 Ubuntu-4ubuntu2.8, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /home/user/Desktop/ssh_keys/scp_config
debug1: /home/user/Desktop/ssh_keys/scp_config line 1: Applying options for prod
debug1: Connecting to ***.***.***.*** [***.***.***.***] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: certificate file /home/user/Desktop/ssh_keys/prod.pem type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 174.129.126.138:22 as 'ec2-user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ****************
SHA256: ********************
debug1: Host '***.***.***.*** is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:8
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

我的设置有什么问题?

【问题讨论】:

  • 嘿,我的问题有什么问题吗?你能在评论中写下你的建议吗?
  • 这个问题似乎更适合superuser.com。这个问题似乎与help center 中定义的范围内的编程无关。
  • @Molecular Man,这个问题我该怎么办?删除此问题并将副本发布到 superuser.com?
  • 我不知道。由你决定。如果您认为这个问题对其他人有用,那么在超级用户处重新发布这个问题可能是个好主意,因为这个问题可能会被关闭

标签: amazon-web-services ssh


【解决方案1】:

您应该使用 IdentityFile 参数来指定您的私钥。

身份文件 指定用户的 RSA 身份验证的文件 身份被读取。

scp_config:

Host prod
    HostName ***.***.***.***
    User ec2-user
    IdentityFile ~/Desktop/ssh_keys/prod.pem

CertificateFile 指定从中读取用户证书的文件。对应的私有 必须单独提供密钥才能使用此证书,无论是从 ssh 的 IdentityFile 指令或 -i 标志

IdentityFile 也可以与 CertificateFile 结合使用,以提供身份验证所需的任何证书。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-05
    • 1970-01-01
    • 2013-06-11
    • 1970-01-01
    • 2011-12-04
    • 1970-01-01
    相关资源
    最近更新 更多