Amazon web services 为什么ssh连接使用-i标志而不是使用-F标志?

Amazon web services 为什么ssh连接使用-i标志而不是使用-F标志?,amazon-web-services,ssh,Amazon Web Services,Ssh,我使用Ubuntu 16.04 我想通过单独的配置文件建立到amazon服务的ssh连接 我还需要将文件从一台服务器传输到另一台服务器,并建议使用单独的配置文件 当我使用它时,它会连接 ssh -i ~/Desktop/ssh_keys/prod.pem ec2-user@***.***.***.*** 但当我使用单独的配置时: ssh -F ~/Desktop/ssh_keys/scp_config prod scp_配置: Host prod HostName ***.***.*

我使用Ubuntu 16.04

我想通过单独的配置文件建立到amazon服务的ssh连接

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

当我使用它时,它会连接

ssh -i ~/Desktop/ssh_keys/prod.pem ec2-user@***.***.***.***
但当我使用单独的配置时:

ssh -F ~/Desktop/ssh_keys/scp_config prod
scp_配置

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).
调试信息:

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).
OpenSSH_7.2p2 Ubuntu-4ubuntu2.8,OpenSSL 1.0.2g 2016年3月1日
debug1:读取配置数据/home/user/Desktop/ssh\u keys/scp\u config
debug1:/home/user/Desktop/ssh_keys/scp_config第1行:应用产品选项
debug1:正在连接到******.***.[***.***.***.***.**]端口22。
debug1:已建立连接。
debug1:永久\u设置\u uid:0/0
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/root/.ssh/id_rsa type-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:标识文件/root/.ssh/id_dsa类型-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/root/.ssh/id_ecdsa type-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/root/.ssh/id_ed25519 type-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:证书文件/home/user/Desktop/ssh\u keys/prod.pem type-1
debug1:启用协议2.0的兼容模式
debug1:本地版本字符串SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
debug1:远程协议版本2.0,远程软件版本OpenSSH_7.4
debug1:匹配:OpenSSH_7.4 pat OpenSSH*compat 0x04000000
debug1:将174.129.126.138:22验证为“ec2用户”
debug1:SSH2\u MSG\u KEXINIT已发送
debug1:SSH2\u MSG\u KEXINIT已收到
debug1:kex:算法:curve25519-sha256@libssh.org
debug1:kex:主机密钥算法:ecdsa-sha2-nistp256
debug1:kex:server->client cipher:chachacha20-poly1305@openssh.comMAC:压缩:无
debug1:kex:client->server cipher:chachacha20-poly1305@openssh.comMAC:压缩:无
debug1:需要SSH2\u MSG\u KEX\u ECDH\u回复
debug1:服务器主机密钥:****************
SHA256:********************
debug1:主机'***.*.*.*.**已知,并且与ECDSA主机密钥匹配。
debug1:在/root/.ssh/known_hosts中找到密钥:8
debug1:在134217728块之后重新键入
debug1:SSH2\u MSG\u已发送新密钥
debug1:应为SSH2\u MSG\u NEWKEYS
debug1:SSH2\u MSG\u接收到新密钥
debug1:在134217728块之后重新键入
debug1:SSH2\u MSG\u EXT\u接收到信息
debug1:kex_输入_外部_信息:服务器信号algs=
debug1:SSH2\u消息\u服务\u接收
debug1:可以继续的身份验证:公钥
debug1:下一个身份验证方法:公钥
debug1:正在尝试私钥:/root/.ssh/id\u rsa
debug1:正在尝试私钥:/root/.ssh/id\u dsa
debug1:正在尝试私钥:/root/.ssh/id\u ecdsa
debug1:正在尝试私钥:/root/.ssh/id_ed25519
debug1:不再尝试验证方法。
权限被拒绝(公钥)。

我的设置有什么问题?

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

IdentityFile 指定用户的RSA身份验证来自的文件 身份被读取

scp_配置:

Host prod
    HostName ***.***.***.***
    User ec2-user
    IdentityFile ~/Desktop/ssh_keys/prod.pem
CertificateFile指定从中读取用户证书的文件。相应的私人 必须单独提供密钥,才能从 IdentityFile指令或ssh的-i标志

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


嘿,我的问题怎么了?你能在评论中写下你的建议吗?这个问题似乎更适合你。这个问题似乎不是关于在《分子人》中定义的范围内编程的,我该如何处理这个问题?删除这个问题并在superuser.com上发布副本?我不知道。这取决于你。如果您认为这个问题对其他人有用,那么将这个问题转发给超级用户可能是一个好主意,因为这个问题可能即将结束