SSHはどのキーを使用するのですか?

SSHはどのキーを使用するのですか?

強制コマンドとして次のコマンドを使用します。HG-SSH

この強制コマンドは、hgを使用したプッシュのみを許可するためのものです。しかし、実際にこのキーでログインできるので何か間違っているようです。私はこのキーをしばらく使ってきましたが、このキーを使ってログインしようとするとすぐにログアウトすることになります。

私は以下を持っています.ssh/authorized_keys

command="cd /srv/hg/faheem && find . -mindepth 1 -maxdepth 4 -type d -exec /usr/bin/hg-ssh {} +",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa public_key

これに対する明確な答えがあるようですが、シェルコマンドが何であるかさえわかりません。

cd /srv/hg/faheem && find . -mindepth 1 -maxdepth 4 -type d -exec /usr/bin/hg-ssh {} +

正確にやっています。

Stack Exchange が自動的に作成します。この関連質問2011年に問い合わせましたが、ちょっと忘れてしまって一度もしなかったようですね。@Gillesの答え

修正する:同じローカルリモートコンビネーションの2つのキーがあります。そのうちの1つはからの一般キーに設定されています~/.ssh/authorized_keys。つまり、

ssh-rsa public_key

もう一つは上記のものです。では、一般キーが最初にリストされ、強制コマンドキーが2番目にリストされます~/.ssh/authorized_keys。 「一般」キーの出力で判断するとssh -vvv使用されているのです。以下は関連するクライアントセクションです.ssh/config

Host ramnode
Hostname xx.x.xxx.xxx
ForwardX11 yes

Host ramnode_hg
Hostname xx.x.xxx.xxx
ForwardX11 yes
identityfile ~/.ssh/id_rsa_bulldog_hg

1つ目は「一般」キー、2つ目は強制コマンドキーです。

おそらく、どのキーを使うべきかを指定する方法がないかもしれませんし、sshは~/.ssh/authorized_keys何かが機能するまで順番にキーを試すだけです。

アップデート2:強制コマンドキーを最初に使用してキーの順序を切り替えてみました~/.ssh/authorized_keysが、そうでないようです。行為

ssh ramnode_hg

それでもマシンにログインできます。

アップデート3:ssh -vvvマシンにログインすると出力されます。

OpenSSH_6.0p1 Debian-4+deb7u1, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /home/faheem/.ssh/config
debug1: /home/faheem/.ssh/config line 122: Applying options for ramnode_hg
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 xx.x.xxx.xxx [xx.x.xxx.xxx] port 22.
debug1: Connection established.
debug3: Incorrect RSA1 identifier
debug3: Could not load "/home/faheem/.ssh/id_rsa_bulldog_hg" as a RSA1 public key
debug1: identity file /home/faheem/.ssh/id_rsa_bulldog_hg 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/faheem/.ssh/id_rsa_bulldog_hg-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1 Debian-4+deb7u1
debug1: match: OpenSSH_6.0p1 Debian-4+deb7u1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u1
debug2: fd 3 setting O_NONBLOCK
debug3: load_hostkeys: loading entries for host "xx.x.xxx.xxx" from file "/home/faheem/.ssh/known_hosts"
debug3: load_hostkeys: found key type ECDSA in file /home/faheem/.ssh/known_hosts:68
debug3: load_hostkeys: loaded 1 keys
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-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],ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,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,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,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: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,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,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
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: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
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 4e:66:01:8f:a1:44:f6:d9:01:e4:72:ff:6a:ab:8e:31
debug3: load_hostkeys: loading entries for host "xx.x.xxx.xxx" from file "/home/faheem/.ssh/known_hosts"
debug3: load_hostkeys: found key type ECDSA in file /home/faheem/.ssh/known_hosts:68
debug3: load_hostkeys: loaded 1 keys
debug1: Host 'xx.x.xxx.xxx' is known and matches the ECDSA host key.
debug1: Found key in /home/faheem/.ssh/known_hosts:68
debug1: ssh_ecdsa_verify: signature correct
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: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/faheem/.ssh/id_rsa (0x7f81f0ca2550)
debug2: key: /home/faheem/.ssh/id_rsa_bb (0x7f81f0ca23b0)
debug2: key: /home/faheem/.ssh/id_rsa_bulldog_hg (0x7f81f0c9d590)
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/faheem/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug2: input_userauth_pk_ok: fp a1:78:e9:c1:f4:9c:5e:23:a3:d9:38:35:be:0a:b4:8b
debug3: sign_and_send_pubkey: RSA a1:78:e9:c1:f4:9c:5e:23:a3:d9:38:35:be:0a:b4:8b
debug1: Authentication succeeded (publickey).
Authenticated to xx.x.xxx.xxx ([xx.x.xxx.xxx]:22).
debug2: fd 5 setting O_NONBLOCK
debug3: fd 6 is O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug2: callback start
debug2: x11_get_proto: /usr/bin/xauth  list :0 2>/dev/null
debug1: Requesting X11 forwarding with authentication spoofing.
debug2: channel 0: request x11-req confirm 1
debug2: client_session2_setup: id 0
debug2: fd 3 setting TCP_NODELAY
debug3: packet_set_tos: set IP_TOS 0x10
debug2: channel 0: request pty-req confirm 1
debug1: Sending environment.
debug3: Ignored env FULLNAME
debug3: Ignored env SSH_AGENT_PID
debug3: Ignored env KDE_MULTIHEAD
debug3: Ignored env DM_CONTROL
debug3: Ignored env TERM
debug3: Ignored env SHELL
debug3: Ignored env HISTSIZE
debug3: Ignored env XDM_MANAGED
debug3: Ignored env XDG_SESSION_COOKIE
debug3: Ignored env GTK2_RC_FILES
debug3: Ignored env KONSOLE_DBUS_SERVICE
debug3: Ignored env CVSROOT
debug3: Ignored env GS_LIB
debug3: Ignored env GTK_RC_FILES
debug3: Ignored env WINDOWID
debug3: Ignored env OLDPWD
debug3: Ignored env SHELL_SESSION_ID
debug3: Ignored env KDE_FULL_SESSION
debug3: Ignored env HISTFILESIZE
debug3: Ignored env USER
debug3: Ignored env LS_COLORS
debug3: Ignored env SSH_AUTH_SOCK
debug3: Ignored env SESSION_MANAGER
debug3: Ignored env COLUMNS
debug3: Ignored env PATH
debug3: Ignored env DESKTOP_SESSION
debug3: Ignored env PWD
debug3: Ignored env EDITOR
debug3: Ignored env PSQL_EDITOR
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug3: Ignored env KDE_SESSION_UID
debug3: Ignored env PYTHONSTARTUP
debug3: Ignored env KONSOLE_DBUS_SESSION
debug3: Ignored env HISTCONTROL
debug3: Ignored env GPG_TTY
debug3: Ignored env CVS_SSH
debug3: Ignored env SHLVL
debug3: Ignored env COLORFGBG
debug3: Ignored env HOME
debug3: Ignored env KDE_SESSION_VERSION
debug3: Ignored env LANGUAGE
debug3: Ignored env XCURSOR_THEME
debug3: Ignored env LOGNAME
debug3: Ignored env DBUS_SESSION_BUS_ADDRESS
debug3: Ignored env XDG_DATA_DIRS
debug3: Ignored env LESSOPEN
debug3: Ignored env LVM_SUPPRESS_FD_WARNINGS
debug3: Ignored env EMAIL
debug3: Ignored env PROMPT_COMMAND
debug3: Ignored env WINDOWPATH
debug3: Ignored env ALTERNATE_EDITOR
debug3: Ignored env DISPLAY
debug3: Ignored env PROFILEHOME
debug3: Ignored env QT_PLUGIN_PATH
debug3: Ignored env RSYNC_RSH
debug3: Ignored env LESSCLOSE
debug3: Ignored env XAUTHORITY
debug3: Ignored env _
debug2: channel 0: request shell confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel_input_status_confirm: type 99 id 0
debug2: X11 forwarding request accepted on channel 0
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
Linux faheem 2.6.32-042stab079.6 #1 SMP Mon Aug 26 19:47:50 MSK 2013 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Apr 10 01:43:43 2014 from [localhost]

アップデート4:SSHエージェントが実行中で、ssh-add -Lがキーをロードしたことを確認しました。

ベストアンサー1

これ顧客送信するキーを選択してください。実際には、詳細なクライアント出力でこれを確認できます。

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/faheem/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 277

クライアントはこのキーで自分の身元を証明することを提案します(プロトコル2の主キー位置リストの最初のキーであるため、クライアントはこのキーを選択し、リスト全体はssh(1)マンページにあります)。 Authorized_keys ファイルを確認します。キーが承認されたことが確認されたら、「OK」と表示されます。その後、クライアントはキーを使用して自分の身元を証明します。

debug2: input_userauth_pk_ok: fp a1:78:e9:c1:f4:9c:5e:23:a3:d9:38:35:be:0a:b4:8b
debug3: sign_and_send_pubkey: RSA a1:78:e9:c1:f4:9c:5e:23:a3:d9:38:35:be:0a:b4:8b
debug1: Authentication succeeded (publickey).
Authenticated to xx.x.xxx.xxx ([xx.x.xxx.xxx]:22).

デフォルトでは、これを指定すると、IdentityFilessh-agentにすでにロードされている項目に加えて検索するファイルのみを提供します(またはssh-add -lを実行して確認できますssh-add -L)。言うただ指定したファイルを使用してください。このファイルもIdentitiesOnly yes構成に追加する必要があります。

おすすめ記事