SSH는 -i 스위치를 무시합니다.

SSH는 -i 스위치를 무시합니다.

기본이 아닌 ID 파일을 사용하여 SSH를 통해 호스팅 회사에 연결하려고 하면 성공적으로 연결되지만 기본 키를 사용합니다.

내가 사용하는 명령은 다음과 같습니다.

ssh -vvv -i ~/.ssh/backup user@server

그리고 출력은 다음과 같습니다.

OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 53: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to server [xx.xxx.xxx.xx] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug3: Incorrect RSA1 identifier
debug3: Could not load "/Users/xxx/.ssh/backup" as a RSA1 public key
debug1: identity file /Users/xxx/.ssh/backup type 1
debug1: identity file /Users/xxx/.ssh/backup-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5*
debug2: fd 3 setting O_NONBLOCK
debug3: load_hostkeys: loading entries for host "server" from file "/var/root/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /var/root/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],ssh-rsa
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: 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],ssh-rsa,[email protected],[email protected],ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],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,[email protected],[email protected],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],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,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],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,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: 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
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-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],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: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 136/256
debug2: bits set: 497/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 1f:56:77:b9:8f:05:d7:c8:ce:5d:7d:b3:0a:e1:30:8c
debug3: load_hostkeys: loading entries for host "server" from file "/var/root/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /var/root/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys
debug3: load_hostkeys: loading entries for host "xx.xxx.xxx.xx" from file "/var/root/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /var/root/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys
debug1: Host 'server' is known and matches the RSA host key.
debug1: Found key in /var/root/.ssh/known_hosts:1
debug2: bits set: 508/1024
debug1: ssh_rsa_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: /Users/xxx/.ssh/id_rsa (0x7f88b05016b0),
debug2: key: /Users/xxx/.ssh/backup (0x7f88b040b1c0), explicit
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
debug3: preferred 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: /Users/xxx/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 535
debug2: input_userauth_pk_ok: fp 76:9b:82:f1:32:91:a8:3a:f2:e3:ce:b8:df:70:88:42
debug3: sign_and_send_pubkey: RSA 76:9b:82:f1:32:91:a8:3a:f2:e3:ce:b8:df:70:88:42
debug1: Authentication succeeded (publickey).
Authenticated to server ([xx.xxx.xxx.xx]:22).
debug2: fd 6 setting O_NONBLOCK
debug3: fd 7 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: fd 3 setting TCP_NODELAY
debug3: packet_set_tos: set IP_TOS 0x08
debug2: client_session2_setup: id 0
debug1: Sending environment.
debug3: Ignored env SHELL
debug3: Ignored env TERM
debug3: Ignored env USER
debug3: Ignored env SUDO_USER
debug3: Ignored env SUDO_UID
debug3: Ignored env SSH_AUTH_SOCK
debug3: Ignored env __CF_USER_TEXT_ENCODING
debug3: Ignored env USERNAME
debug3: Ignored env LSCOLORS
debug3: Ignored env MAIL
debug3: Ignored env PATH
debug3: Ignored env PWD
debug3: Ignored env EDITOR
debug1: Sending env LANG = fr_FR.UTF-8
debug2: channel 0: request env confirm 0
debug3: Ignored env SHLVL
debug3: Ignored env SUDO_COMMAND
debug3: Ignored env COLORFGBG
debug3: Ignored env HOME
debug3: Ignored env LOGNAME
debug1: Sending env LC_CTYPE = fr_FR.UTF-8
debug2: channel 0: request env confirm 0
debug3: Ignored env SUDO_GID
debug3: Ignored env DISPLAY
debug3: Ignored env _
debug1: Sending command: whoami
debug2: channel 0: request exec confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0

백업 개인 키의 권한:

-rw-------  1 xxx  staff  1675 28 nov 00:30 /Users/sbooob/.ssh/backup

xxx 사용자와 루트 사용자로 ssh 명령을 실행해 보았지만 결과는 동일했습니다.

내 말이 맞다면 SSH는 내가 사용하려는 키( )를 읽은 다음 이전에 키를 시도하지 않고도 debug1: identity file /Users/xxx/.ssh/backup type 1기본 키를 사용하여 서버( )에 로그인합니다 .debug1: Offering RSA public key: /Users/xxx/.ssh/id_rsabackup

서버에 있는 파일 의 기본 키에 해당하는 줄을 주석 처리하면 authorized_keys해당 키를 사용하여 연결됩니다 backup.

SSH가 명령줄에 지정된 ID 파일을 사용하여 로그인을 시도하지 않는 이유를 아는 사람이 있습니까?

답변1

노력하다:

ssh -vvv -i ~/.ssh/backup -o IdentitiesOnly=yes user@server

이렇게 하면 를 통해 사용 가능한 모든 키가 비활성화됩니다 ssh-agent.

답변2

도움을 드리고 싶지만 댓글을 달 수 있는 권한이 없어 답변으로 이렇게 글을 남깁니다.

디버깅에 도움이 될 것이라고 생각되는 두 가지 사항이 있습니다.

  1. debug3 출력 ssh(-vvv)
  2. ~/.ssh/backup의 권한 알기

특히 다음과 같이 도움이 될 수 있는 debug3 메시지가 있습니다.

debug3: Could not load "/Users/xxx/.ssh/backup" as a RSA1 public key

관련 정보