-i を使用してキーを指定した場合にのみ、SSH は機能します。

-i を使用してキーを指定した場合にのみ、SSH は機能します。

キーを持つSSHのみを許可するサーバーがあります。ただし、SSHを介してこのコンピュータに接続しようとすると、「権限が拒否されました(公開鍵)」というエラーが発生します。私のサーバーのauth.logを見ると、認証前にこれが起こります。私のキーと.sshフォルダの権限は大丈夫です。また、sshを試すときに-vvを使用すると、正しいキーファイルを使用しようとしていないようです。

動作する唯一の方法は、-i argを使用してキーパスを指定することです。 (私の.sshフォルダにあります)私は以前にキーをインストールしましたが、問題はありませんでした。唯一の違いは、今回はssh-copy-idを使用する代わりにキーファイルをサーバーにscpしてから、cat >>を使用して認証されたキーファイルに追加する必要があることです。

サーバーを一時的に不安定にし、ssh-copy-idを使用せずに問題をさらにデバッグまたは解決する方法を知っている人はいますか?

-vv出力(何らかの理由で有効なキーは試行されません。)

OpenSSH_6.7p1 Raspbian-5+deb8u2, OpenSSL 1.0.1k 8 Jan 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to $host [$ip address] port $port.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/ben/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ben/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ben/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ben/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ben/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ben/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ben/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ben/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Raspbian-5+deb8u2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.7p1 Debian-5+deb8u2
debug1: match: OpenSSH_6.7p1 Debian-5+deb8u2 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],[email protected],arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],[email protected],arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1,[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1,[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],[email protected]
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_setup: setup [email protected]
debug1: kex: server->client aes128-ctr [email protected] none
debug2: mac_setup: setup [email protected]
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 10:b9:0c:fa:8f:69:f2:eb:84:bd:69:32:50:1b:dd:ee
debug1: Host '$host' is known and matches the ECDSA host key.
debug1: Found key in /home/ben/.ssh/known_hosts:1
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/ben/.ssh/id_rsa ((nil)),
debug2: key: /home/ben/.ssh/id_dsa ((nil)),
debug2: key: /home/ben/.ssh/id_ecdsa ((nil)),
debug2: key: /home/ben/.ssh/id_ed25519 ((nil)),
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/ben/.ssh/id_rsa
debug1: Trying private key: /home/ben/.ssh/id_dsa
debug1: Trying private key: /home/ben/.ssh/id_ecdsa
debug1: Trying private key: /home/ben/.ssh/id_ed25519
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).

カタログおよび内容の詳細情報.ssh

ls - ld
drwxr-xr-x 2 $user $user .

ls -l
total 16
-rw------- 1 $user $user 733 May 3 16:27 authorized_keys
-rw------- 1 $user $user 3243 May 9 15:33 key 
-rw-r--r-- 1 $user $user 751 May 9 15:33 key.pub 
-rw-r--r-- 1 $user $user 444 May 9 15:31 known_hosts

ベストアンサー1

私が知っている限り、同じssh名前のキーid_rsaid_dsa他のいくつかのキーのみが検索され、すべてid_質問出力に表示される方法で始まります。別の名前のキーがある場合は、コマンドラインまたはSSH構成ファイルでそれらを指定する必要があります。

keysshが検索するファイル名にファイル名を変更するか、.ssh/config関連セクションに更新するか、この-iオプションを使用してください。

このようなものを使用できます.ssh/config

host my.target.server
IdentityFile ~/.ssh/key

また、使用することができます、

host *
IdentityFile ~/.ssh/key

~/.ssh/keyすべての接続にSSHを強制します。

id_dsaキーファイルの名前を変更する方が簡単かもしれませんid_rsa(そのファイルがkey実際に出力から呼び出されると仮定します)。

おすすめ記事