강제 명령으로 다음 명령을 사용합니다.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의 답변.
고쳐 쓰다:동일한 로컬-원격 조합에 대한 두 개의 키가 있습니다. 그 중 하나는 에서 일반 키로 설정되어 있습니다 ~/.ssh/authorized_keys
. 즉, 그것은 다음과 같습니다
ssh-rsa public_key
다른 하나는 위에 주어진 것입니다. 에서는 일반 키가 먼저 나열되고 강제 명령 키가 두 번째로 나열됩니다 ~/.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
첫 번째는 "일반" 키이고 두 번째는 강제 명령 키입니다.
어쩌면 어떤 키를 사용해야 하는지 지정할 방법이 없을 수도 있고, 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).
기본적으로 이를 지정하면 IdentityFile
ssh-agent에 이미 로드된 항목 외에 검색할 파일만 제공합니다( ssh-add -l
또는 를 실행하여 이를 확인할 수 있습니다 ssh-add -L
). 말해오직지정한 파일을 사용하십시오. 이 파일도 IdentitiesOnly yes
구성에 추가해야 합니다.