首页 文章

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

提问于
浏览
1

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

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

  • adduser -g root

  • mkdir /home//.ssh

  • 将我的公钥复制到/home//.ssh/authorized_keys

  • chmod 700 /home//.ssh

  • chmod 600 /home//.ssh/authorized_keys

在rackspace Cloud 中的服务器配置文件中:

  • RSAAuthentication是的

  • PubkeyAuthentication是的

  • #AuthorizedKeysFile .ssh / authorized_keys

当我尝试“ssh -i my_priv_key @server_ip”时,它失败并要求我输入@server_ip的密码 .

当我将以下行添加到服务器上的sshd_config时,它表示权限被拒绝(publickey,gssapi-keyex,gssapi-with-mic) .

匹配用户密码验证号

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

3 回答

  • 0

    对于使用Rackspace API进行自动化,您不希望向您显示将您的SSH密钥放在服务器上的情况 . [1398545]例如,如果你正在使用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密钥位于“ Cloud 控制”面板中的“设置”和“联系人”中,位于安全问题下方:

    API Key

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

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

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

    ssh -i my_priv_key root@<ip>
    

    如果Python不是't your preferred language, there are other options. You can also make direct requests/use curl if that'你的东西,因为这是Rackspace APIOpenStack/nova proper的一部分 .

  • 0

    您是否检查了服务器上的权限和时间设置 . 此外,你有意删除帖子中的用户名 .

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

  • 1

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

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

相关问题