AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 35753
Accepted
Chris Bunch
Chris Bunch
Asked: 2009-07-04 15:38:50 +0800 CST2009-07-04 15:38:50 +0800 CST 2009-07-04 15:38:50 +0800 CST

EC2 - 使用 oa 密钥或密码登录自己

  • 772

我希望能够ssh进入我的节点,然后运行用于其自身目的ssh的软件,进入其他机器和自身。它假定ssh已经设置了密钥,因此它不能获取-i标志并使用它。

我有一个可以正常工作的 Xen 设置:我所要做的就是 scp 我的私钥.ssh/id_rsa和公共部分.ssh/id_rsa.pub(我可以在 EC2 中恢复它,因为它在.ssh/authorized_keys.

同样的设置在 EC2 中根本不起作用。我已经验证了这一点,/etc/ssh/sshd_config并且/etc/ssh/ssh_config在我的 Xen 盒子和 EC2 盒子上都一样。

我使用的基础 AMI 是ami-1774927eAlestic.com 映像,其中包含全新的 Ubuntu Hardy 安装。当然,我的安全组中的 22 端口是开放的,可用于ssh流量。

关于我做错了什么的任何想法?

编辑:根据 womble 在 Amazon EC2 论坛上的建议和建议,这里有可能有用的额外信息:

sshd_config并且ssh_config在我的 Xen 和 EC2 机器上是相同的(并且是前面指定的 Alestic ami 附带的默认机器),而且我没有使用任何命令行选项。ssh-agent没有运行,并且机器上没有其他ssh键。我只以 root 身份登录,最重要的是,如果我在密钥名不是时使用 -i,我可以从同一个框登录我的 EC2 框id_rsa。

当我使用 -i 标志时, ssh -v 的尾部看起来像这样:

debug1: Host 'localhost' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: ec2scale.key
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Last login: Mon Jul  6 23:42:49 2009 from 127.0.0.1
Linux (none) 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:34:28 EST 2008 x86_64
... and so on ...

但是当我不使用 -i 标志时,我得到了这个:

debug1: Host 'localhost' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Offering public key: /root/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: Trying private key: /root/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).

我已经diff编辑了密钥并且它们是相同的,我可以看到服务器接受了我上面的 id_rsa 密钥,但只是身份验证没有通过。当我登录时,签出/var/log/auth.log显示如下:

Jul  6 23:46:09 ip-10-244-50-159 sshd[1354]: error: RSA_public_decrypt failed: error:0407006A:lib(4):func(112):reason(106)

我可以用它openssl来查看以下错误代码:

root@ip:~# openssl errstr 0407006A
error:0407006A:rsa routines:RSA_padding_check_PKCS1_type_1:block type is not 01 

但我不确定如何使用它来解决我的问题。

amazon-ec2 ssh
  • 2 2 个回答
  • 2882 Views

2 个回答

  • Voted
  1. Best Answer
    Chris Bunch
    2009-07-19T20:54:04+08:002009-07-19T20:54:04+08:00

    在 Amazon EC2 论坛上进行了大量工作后,“解决方案”是简单地将密钥命名为id_rsa. 由于唯一可以自动使用的其他键名是id_dsa,因此我命名了该键并且它起作用了。该线程显示了调试问题所采取的步骤,如果将来的读者遇到类似问题,请在此处复制这些步骤。

    • 的内容/etc/ssh/sshd_config
    • 的内容/etc/ssh/ssh_config
    • 的内容$HOME/.ssh/authorized_keys
    • 的内容$HOME/.ssh/config
    • 目录和文件的权限
    • 您正在使用的命令行选项(例如,-I和-A)
    • 您正在使用的用户名
    • SSH_*环境变量
    • ssh-agent状态和哪些键已被ssh-add编辑
    • ssh -v -i $HOME/.ssh/id_rsa <REMOTE>
    • ssh -v <REMOTE>
    • strace ssh -v -i $HOME/.ssh/id_rsa <REMOTE>
    • sshd使用调试标志运行-d
    • 通过复制id_rsa到解决id_dsa,确保没有id_dsa.pub(或它不会工作)
    • 2
  2. womble
    2009-07-04T16:55:43+08:002009-07-04T16:55:43+08:00

    好吧,如果没有身份验证日志的内容来查看 SSH 服务器的想法,以及 SSH 客户端的详细运行的输出,我唯一能提供的猜测是配置错误。

    编辑:所以,除非我误解你,否则你可以很好地登录 EC2 机器,除非你不使用正确的密钥?

    • 1

相关问题

  • Windows SSH 客户端

  • 在 Windows Server 2003 上通过 SSH 启动和停止 Mongrel 服务

  • 隧道 Xbox 网络流量 [关闭]

  • 系统映像食谱?

  • 为什么使用authorized_keys通过ssh自动登录不起作用?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    Windows 中执行反向 DNS 查找的命令行实用程序是什么?

    • 14 个回答
  • Marko Smith

    如何检查 Windows 机器上的端口是否被阻塞?

    • 4 个回答
  • Marko Smith

    我应该打开哪个端口以允许远程桌面?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    kch 如何更改我的私钥密码? 2009-08-06 21:37:57 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve