RSA キーを使用して SSH トンネル経由でログインしても、パスワード プロンプトが表示される

RSA キーを使用して SSH トンネル経由でログインしても、パスワード プロンプトが表示される

私は動的IPアドレスを持つ2台のラップトップ(ホストAとホストC)と1台のデスクトップ(ホストB)を持っており、それらはすべて(Ubuntu)Linuxを実行しています。現在、ホストCからホストAにアクセスできるように設定しています。ホストAで次の形式のコマンドを使用して、AからCへのsshトンネルがあります。

autossh -NR 10023:localhost:22 [email protected]

autossh コマンドが実際に実行できるように、キー ペアリングを使用しています。

次にCからBにsshで接続し、

ssh -p 10023 localhost

パスワードの入力を求められ、ログインできます。問題はありません。

しかし、Aのセキュリティを強化して、ログインにキーが必要になるようにしたいです。そこで、ホストBでキーのペアをssh-keygenし、キーにcustomkey_rsaという名前を付けてパスワードを設定します。すると、customkey_rsa.pubが公開キーになります。このトンネルではssh-copy-idが機能しないので、CからAにログインし、ホストBからcustomkey_rsa.pubをscpします。次に、キーに

cd .ssh & cat customkey_rsa.pub >> authorized_keys

しかし、ログインしようとすると、まだパスワードプロンプトが表示されます。実際、キーを試すところまでは行くようですが、どういうわけか最後の瞬間に諦めてしまいます。

Bから

ssh -v -i customkey_rsa -p 10023 localhost

与える

OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Connecting to localhost [127.0.0.1] port 10023.
debug1: Connection established.
debug1: identity file customkey_rsa type 1
debug1: identity file customkey_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA (redacted)
debug1: Host '[localhost]:10023' is known and matches the ECDSA host key.
debug1: Found key in /home/ohnoplus/.ssh/known_hosts:2
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: customkey_rsa
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password 
ohnoplus@localhost's password: 

~/.sshホスト A のの権限はであり700、の の権限は で.ssh/authorized_keysあることに注意してください600

それで私の質問です。なぜこれが機能しなかったのでしょうか、そしてどうすれば修正できるのでしょうか?

私が調べたが役に立たなかったもの:

提案リストに従って作業しました。私のシステムでは権限が正しく設定されており、他の解決策は適用されません。 公開鍵認証を使用した SSH でパスワードプロンプトが表示されるのはなぜですか?

同様ですが、解決策は提供されていません: rsaキーを使用したsshはパスワードを要求する

「authorized_keys2」ファイルがありません .ssh/authorized_keys にもかかわらず、ssh がパスワードを要求する

答え1

以下を追加する必要があります:

PasswordAuthentication no

sshd_config(サーバーの設定)に

関連情報