背景
电脑 .ssh 有多对公私钥,那么怎么确定电脑在用哪个公私钥在和服务器通信呢?
操作
命令行执行ssh -T -v git@github.com
然后找到 Server accepts key 就能电脑用这个私钥在通信,那么和它配对的公钥就是配置在服务端
例子
vz4qt9@CNMACANCN57RH76 ~/.ssh ssh -T -v git@github.com
OpenSSH_9.9p2, LibreSSL 3.3.6
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/100-macos.conf
debug1: /etc/ssh/ssh_config.d/100-macos.conf line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/crypto.conf
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to github.com port 22.
debug1: Connection established.
debug1: identity file /Users/vz4qt9/.ssh/id_rsa type 0
debug1: identity file /Users/vz4qt9/.ssh/id_rsa-cert type -1
debug1: identity file /Users/vz4qt9/.ssh/id_ecdsa type -1
debug1: identity file /Users/vz4qt9/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/vz4qt9/.ssh/id_ecdsa_sk type -1
debug1: identity file /Users/vz4qt9/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /Users/vz4qt9/.ssh/id_ed25519 type 3
debug1: identity file /Users/vz4qt9/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/vz4qt9/.ssh/id_ed25519_sk type -1
debug1: identity file /Users/vz4qt9/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /Users/vz4qt9/.ssh/id_xmss type -1
debug1: identity file /Users/vz4qt9/.ssh/id_xmss-cert type -1
debug1: identity file /Users/vz4qt9/.ssh/id_dsa type -1
debug1: identity file /Users/vz4qt9/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.9
debug1: Remote protocol version 2.0, remote software version 550beff
debug1: compat_banner: no match: 550beff
debug1: Authenticating to github.com:22 as 'git'
debug1: load_hostkeys: fopen /Users/vz4qt9/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: ecdh-sha2-nistp256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: aes128-gcm@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: aes128-gcm@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU
debug1: load_hostkeys: fopen /Users/vz4qt9/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host 'github.com' is known and matches the ED25519 host key.
debug1: Found key in /Users/vz4qt9/.ssh/known_hosts:1
debug1: ssh_packet_send2_wrapped: resetting send seqnr 3
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: ssh_packet_read_poll2: resetting read seqnr 3
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 4294967296 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa>
debug1: kex_ext_info_check_ver: publickey-hostbound@openssh.com=<0>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: ssh_fetch_identitylist: agent contains no identities
debug1: Will attempt key: /Users/vz4qt9/.ssh/id_rsa RSA SHA256:sv9nEWMQRl/XDWCq7bm9RYg2452llIGgWtuT3qwfCO8
debug1: Will attempt key: /Users/vz4qt9/.ssh/id_ecdsa
debug1: Will attempt key: /Users/vz4qt9/.ssh/id_ecdsa_sk
debug1: Will attempt key: /Users/vz4qt9/.ssh/id_ed25519 ED25519 SHA256:610FN6XJjMTYrIlwirnpJVdbgeuZG1RtMgX5KEYm2RI
debug1: Will attempt key: /Users/vz4qt9/.ssh/id_ed25519_sk
debug1: Will attempt key: /Users/vz4qt9/.ssh/id_xmss
debug1: Will attempt key: /Users/vz4qt9/.ssh/id_dsa
debug1: Offering public key: /Users/vz4qt9/.ssh/id_rsa RSA SHA256:sv9nEWMQRl/XDWCq7bm9RYg2452llIGgWtuT3qwfCO8
debug1: Server accepts key: /Users/vz4qt9/.ssh/id_rsa RSA SHA256:sv9nEWMQRl/XDWCq7bm9RYg2452llIGgWtuT3qwfCO8
Authenticated to github.com ([198.18.1.4]:22) using "publickey".
debug1: channel 0: new session [client-session] (inactive timeout: 0)
debug1: Entering interactive session.
debug1: pledge: filesystem
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: client_input_hostkeys: searching /Users/vz4qt9/.ssh/known_hosts for github.com / (none)
debug1: client_input_hostkeys: searching /Users/vz4qt9/.ssh/known_hosts2 for github.com / (none)
debug1: client_input_hostkeys: hostkeys file /Users/vz4qt9/.ssh/known_hosts2 does not exist
debug1: client_input_hostkeys: no new or deprecated keys from server
debug1: Sending environment.
debug1: channel 0: setting env LC_TERMINAL_VERSION = "3.5.14"
debug1: channel 0: setting env LANG = "en_AU.UTF-8"
debug1: channel 0: setting env LC_TERMINAL = "iTerm2"
debug1: pledge: fork
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi VZ4QT9_gme! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3532, received 3152 bytes, in 0.7 seconds
Bytes per second: sent 5395.9, received 4815.3
debug1: Exit status 1