簡體   English   中英

在機架空間雲中使用密鑰身份驗證的無密碼ssh失敗:要求輸入密碼

[英]Passwordless ssh using key authentication in rackspace cloud fails: asks for password

我正在嘗試使用公鑰和私鑰機制與機架空間中的cloudserver(運行redhat)進行無密碼ssh連接。

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

  1. adduser -g根
  2. mkdir /home//.ssh
  3. 將我的公鑰復制到/home//.ssh/authorized_keys
  4. chmod 700 /home//.ssh
  5. chmod 600 /home//.ssh/authorized_keys

在機架空間雲中服務器的配置文件中:

  1. RSAAuthentication是
  2. PubkeyAuthentication是
  3. #AuthorizedKeysFile .ssh / authorized_keys

當我嘗試執行“ ssh -i my_priv_key @server_ip”時,它失敗並要求我輸入@server_ip的密碼。

當我將以下行添加到服務器上的sshd_config時,它說權限被拒絕(publickey,gssapi-keyex,gssapi-with-mic)。

匹配用戶密碼身份驗證

我已經嘗試了最近幾個小時,但無法弄清楚。 所以任何想法如何解決這個問題。

這不能完全回答您的問題,但是我想向您展示另一種使用Rackspace API自動化將SSH密鑰放置在服務器上的方法。 例如,如果您使用的是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密鑰

建立服務器后,您應該可以獲取IP地址

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

然后,只需使用您指定的密鑰將ssh作為root用戶即可。

ssh -i my_priv_key root@<ip>

如果Python不是您的首選語言,則還有其他選擇。 您也可以直接請求/使用curl,因為這是Rackspace APIOpenStack / nova屬性的一部分

您是否已檢查服務器上的權限和時間設置。 另外,您是否有意從帖子中刪除了用戶名。

嘗試使用-v選項執行ssh。 這將為調試提供更多輸出。

我發現在遠程服務器上設置SSH密鑰的最簡單方法是使用ssh-copy-id命令。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM