在rackspace云中使用密钥身份验证的无密码ssh失败:要求输入密码

时间:2013-08-28 08:59:13

标签: linux authentication ssh public-key-encryption rackspace-cloud

我正在尝试使用公钥和私钥机制与机架空间中的云服务器(运行redhat)进行无密码ssh连接。

我的命令是(在服务器中):

  1. adduser -g root
  2. mkdir / home //。ssh
  3. 将我的公钥复制到/ home // .ssh / authorized_keys
  4. chmod 700 / home //。ssh
  5. chmod 600 / home //。ssh / authorized_keys
  6. 在rackspace云中的服务器的配置文件中:

    1. RSAAuthentication yes
    2. PubkeyAuthentication yes
    3. #AuthorizedKeysFile .ssh / authorized_keys
    4. 当我尝试“ssh -i my_priv_key @server_ip”时,它失败并要求我输入@server_ip的密码。

      当我在服务器上的sshd_config中添加以下行时,它表示Permission denied(publickey,gssapi-keyex,gssapi-with-mic)。

      匹配用户    PasswordAuthentication no

      过去几个小时我一直在努力,但我无法弄明白。所以任何想法如何解决这个问题。

3 个答案:

答案 0 :(得分:1)

这不能完全回答您的问题,但我想向您展示another way将SSH密钥放在您的服务器上,使用Rackspace API进行自动化。例如,如果您使用pyrax

import pyrax
import os

pyrax.set_setting("identity_type", "rackspace")
pyrax.set_setting("username", USER_NAME) # User name
pyrax.set_setting("api_key", API_KEY) # Located in the control panel in settings

# Could also use a credential file
# pyrax.set_credential_file(os.path.expanduser("~/.rackspace_cloud_credentials"))

# Put your SSH key on the Rackspace cloud
pubkey = open("my_priv_key").read()
cs.keypairs.create("testkey", pubkey)

# For demo purposes, grab a sample image, server type (flavor in OpenStack parlance)
flavor_512 = [flavor for flavor in cs.flavors.list() if flavor.ram == 512][0]
ubu_image = [img for img in cs.images.list() if "Ubuntu 12.04" in img.name][0]

# Now we can create the server and assign an ssh key
server = cs.servers.create("ubbie", ubu_image.id, flavor_512.id,
        key_name="testkey")

您的API密钥位于“云控制”面板的“设置”和“联系人”中,位于安全问题下方:

API Key

构建服务器后,您应该能够获取IP地址

server = cs.servers.get(server.id)
ip = server.accessIPv4

然后使用您指定的密钥以root身份ssh。

ssh -i my_priv_key root@<ip>

如果Python不是您的首选语言,还有其他选择。如果这是你的事,你也可以直接请求/使用curl,因为这是Rackspace APIOpenStack/nova proper的一部分。

答案 1 :(得分:0)

您是否检查过权限&amp;服务器上的时间设置。 此外,你有意从帖子中删除了用户名。

尝试使用-v选项执行ssh。这将为调试提供更多输出。

答案 2 :(得分:0)

我发现在远程服务器上设置SSH密钥的最简单方法是使用ssh-copy-id命令。

http://linux.die.net/man/1/ssh-copy-id

相关问题