
自宅のコンピューターとサーバーがあります。秘密鍵を使用してサーバーにログインしようとしています。
私のサーバーにはユーザーがいてserveruser
、自宅のパソコンからログインするとします。
ssh -Y [email protected]
そして、私の自宅のコンピューターには、ユーザーがいますhomeuser
。
では、秘密鍵を使用してサーバーにログインしたいと思います。そのために、パスフレーズ付きの鍵を にすでに持っています/home/homeuser/.ssh/
。そこで、公開鍵 (id_rsa.pub) を取得し、 にあるサーバーにコピーしました/home/serveruser/.ssh/authorized_keys
。
今、そのキーを使ってログインしたいので、
ssh -Y [email protected]
それでも、パスフレーズではなくパスワードの入力を求められます。
私もログインしてみました
ssh -i /home/homeuser/.ssh/id_rsa -Y [email protected]
そして、まだユーザーパスワードの入力を求められます。
何を間違えたのでしょうか?アドバイスをお願いします。
ご尽力に感謝いたします。
編集:メイソン・ヘラーの推奨に従ってssh-addを実行しましたが、それでもパスワードの入力を求められます。[メールアドレス]。
編集: 情報元: ssh -v -Y myserver.com
(匿名性を保つため個人情報は修正されています)。
OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to myserver.com [100.100.100.100] port 22.
debug1: Connection established.
debug1: identity file /home/homeuser/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/homeuser/.ssh/id_rsa-cert type -1
debug1: identity file /home/homeuser/.ssh/id_dsa type -1
debug1: identity file /home/homeuser/.ssh/id_dsa-cert type -1
debug1: identity file /home/homeuser/.ssh/id_ecdsa type -1
debug1: identity file /home/homeuser/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1 Debian-4
debug1: match: OpenSSH_6.0p1 Debian-4 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA b2:1a:68:21:5a:72:c4:f7:ec:ea:60:12:e4:f8:b5:71
debug1: Host 'myserver.com' is known and matches the ECDSA host key.
debug1: Found key in /home/homeuser/.ssh/known_hosts:11
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/homeuser/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: [email protected]
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/homeuser/.ssh/id_dsa
debug1: Trying private key: /home/homeuser/.ssh/id_ecdsa
debug1: Next authentication method: password
詳しくは:
cat /home/homeuser/.ssh/id_rsa.pub
--removed for security--
/home/serveruser/.ssh/承認済みキー
total 4
-rwx------ 1 serveruser serveruser 400 Jan 26 01:09 id_rsa.pub
cat /home/serveruser/.ssh/authorized_keys
cat: /home/serveruser/.ssh/authorized_keys: Is a directory
答え1
/home/serveruser/.ssh/authorized_keys
ファイルである必要があります。
id_rsa.pub の内容を追加して作成します (つまり、cat /home/homeuser/.ssh/id_rsa.pub >> authorized_keys)。
(当然ですが、最初に公開鍵をサーバーにコピーする必要があります。)
答え2
キーペアを使用するには、認証を処理するために ssh-agent を実行する必要があります。
eval $(ssh-agent)
ssh-add
その後、そのターミナルでのすべての後続の ssh セッションでキーペアが利用できるようになります。 は、ssh-agent
ターミナル セッションに環境変数を追加します。これは、ssh
使用するために必要なものです。 私は通常、ssh-agent > ~/.ssha; . ~/.ssha; ssh-add
1 つの pty で実行し、次にsource ~/.ssha
ssh を使用する必要がある他の pty で実行して、すべての pty がエージェントを使用できるようにします。
また、公開キーをサーバーに追加するのも簡単だと思いますssh-copy-id
。 これで、皆さんの作業も楽になるかもしれません。 :)