WSL的openssh-server使用报错:Could not load host key: /etc/ssh/ssh_host_rsa_key

在WSL中启动openssh-server时遇到错误:Could not load host key: /etc/ssh/ssh_host_rsa_key。解决方法是重新安装ssh,安装过程将自动创建缺失的key,完成后再启动服务即可正常运行。

如果使用自带的openssh-server会报错:

-> # service ssh restart
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Could not load host key: /etc/ssh/ssh_host_ed25519_key
 * Restarting OpenBSD Secure Shell server sshd
Could not load host key: /etc/ssh
[users27@itfeat ~]$ scp -v users27@39.106.197.53:/home/users27/h_b.txt C:/Users/lenovo/Desktop Executing: /usr/bin/ssh -x -oClearAllForwardings=yes -t -v -l users27 -- 39.106.197.53 scp -v /home/users27/h_b.txt C:/Users/lenovo/Desktop OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 58: Applying options for * debug1: Connecting to 39.106.197.53 [39.106.197.53] port 22. debug1: Connection established. debug1: key_load_public: No such file or directory debug1: identity file /home/users27/.ssh/id_rsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/users27/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/users27/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/users27/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/users27/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/users27/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/users27/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/users27/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.4 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4 debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000 debug1: Authenticating to 39.106.197.53:22 as 'users27' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: curve25519-sha256 need=64 dh_need=64 debug1: kex: curve25519-sha256 need=64 dh_need=64 debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:AWAF52HCVTsMe1va15QWzqvp0J+1H/jm2dL4VVXHWwY debug1: Host '39.106.197.53' is known and matches the ECDSA host key. debug1: Found key in /home/users27/.ssh/known_hosts:1 debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey after 134217728 blocks debug1: SSH2_MSG_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password debug1: Next authentication method: gssapi-keyex debug1: No valid Key exchange context debug1: Next authentication method: gssapi-with-mic debug1: Unspecified GSS failure. Minor code may provide more information No Kerberos credentials available (default cache: KEYRING:persistent:1113) debug1: Unspecified GSS failure. Minor code may provide more information No Kerberos credentials available (default cache: KEYRING:persistent:1113) debug1: Next authentication method: publickey debug1: Trying private key: /home/users27/.ssh/id_rsa debug1: Trying private key: /home/users27/.ssh/id_dsa debug1: Trying private key: /home/users27/.ssh/id_ecdsa debug1: Trying private key: /home/users27/.ssh/id_ed25519 debug1: Next authentication method: password users27@39.106.197.53's password: debug1: Authentication succeeded (password). Authenticated to 39.106.197.53 ([39.106.197.53]:22). debug1: channel 0: new [client-session] debug1: Requesting no-more-sessions@openssh.com debug1: Entering interactive session. debug1: pledge: network debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0 debug1: Sending environment. debug1: Sending env LANG = en_US.UTF-8 debug1: Sending command: scp -v /home/users27/h_b.txt C:/Users/lenovo/Desktop Executing: program /usr/bin/ssh host C, user (unspecified), command scp -v -t /Users/lenovo/Desktop OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 58: Applying options for * ssh: Could not resolve hostname c: Name or service not known lost connection debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0 debug1: channel 0: free: client-session, nchannels 1 Connection to 39.106.197.53 closed. Transferred: sent 2368, received 2832 bytes, in 0.1 seconds Bytes per second: sent 26738.6, received 31977.9 debug1: Exit status 1
07-23
ubuntu@VM-0-6-ubuntu:~$ ssh -R 13306:127.0.0.1:3306 -R 18088:127.0.0.1:8088 -i "C:\Windows\My_Superset_Key.pem" ubuntu@43.153.66.149 -N -v Warning: Identity file C:\Windows\My_Superset_Key.pem not accessible: No such file or directory. OpenSSH_9.6p1 Ubuntu-3ubuntu13.14, OpenSSL 3.0.13 30 Jan 2024 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files debug1: /etc/ssh/ssh_config line 21: Applying options for * debug1: Connecting to 43.153.66.149 [43.153.66.149] port 22. debug1: Connection established. debug1: identity file /home/ubuntu/.ssh/id_rsa type -1 debug1: identity file /home/ubuntu/.ssh/id_rsa-cert type -1 debug1: identity file /home/ubuntu/.ssh/id_ecdsa type -1 debug1: identity file /home/ubuntu/.ssh/id_ecdsa-cert type -1 debug1: identity file /home/ubuntu/.ssh/id_ecdsa_sk type -1 debug1: identity file /home/ubuntu/.ssh/id_ecdsa_sk-cert type -1 debug1: identity file /home/ubuntu/.ssh/id_ed25519 type -1 debug1: identity file /home/ubuntu/.ssh/id_ed25519-cert type -1 debug1: identity file /home/ubuntu/.ssh/id_ed25519_sk type -1 debug1: identity file /home/ubuntu/.ssh/id_ed25519_sk-cert type -1 debug1: identity file /home/ubuntu/.ssh/id_xmss type -1 debug1: identity file /home/ubuntu/.ssh/id_xmss-cert type -1 debug1: identity file /home/ubuntu/.ssh/id_dsa type -1 debug1: identity file /home/ubuntu/.ssh/id_dsa-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13.14 debug1: Remote protocol version 2.0, remote software version OpenSSH_9.6p1 Ubuntu-3ubuntu13.14 debug1: compat_banner: match: OpenSSH_9.6p1 Ubuntu-3ubuntu13.14 pat OpenSSH* compat 0x04000000 debug1: Authenticating to 43.153.66.149:22 as 'ubuntu' debug1: load_hostkeys: fopen /home/ubuntu/.ssh/known_hosts: No such file or directory debug1: load_hostkeys: fopen /home/ubuntu/.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: sntrup761x25519-sha512@openssh.com debug1: kex: host key algorithm: ssh-ed25519 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: client->server cipher: chacha20-poly1305@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:SCNCIXYAS8UyHXm9xBmwatnCfmtTo1JQSU6B6FLMhJE debug1: load_hostkeys: fopen /home/ubuntu/.ssh/known_hosts: No such file or directory debug1: load_hostkeys: fopen /home/ubuntu/.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: hostkeys_find_by_key_hostfile: hostkeys file /home/ubuntu/.ssh/known_hosts does not exist debug1: hostkeys_find_by_key_hostfile: hostkeys file /home/ubuntu/.ssh/known_hosts2 does not exist debug1: hostkeys_find_by_key_hostfile: hostkeys file /etc/ssh/ssh_known_hosts does not exist debug1: hostkeys_find_by_key_hostfile: hostkeys file /etc/ssh/ssh_known_hosts2 does not exist The authenticity of host '43.153.66.149 (43.153.66.149)' can't be established. ED25519 key fingerprint is SHA256:SCNCIXYAS8UyHXm9xBmwatnCfmtTo1JQSU6B6FLMhJE. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '43.153.66.149' (ED25519) to the list of known hosts. debug1: ssh_packet_send2_wrapped: resetting send seqnr 3 debug1: rekey out after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: Sending SSH2_MSG_EXT_INFO debug1: expecting SSH2_MSG_NEWKEYS debug1: ssh_packet_read_poll2: resetting read seqnr 3 debug1: SSH2_MSG_NEWKEYS received debug1: rekey in after 134217728 blocks debug1: SSH2_MSG_EXT_INFO received debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256> debug1: kex_ext_info_check_ver: publickey-hostbound@openssh.com=<0> debug1: kex_ext_info_check_ver: ping@openssh.com=<0> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: SSH2_MSG_EXT_INFO received debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256> debug1: Authentications that can continue: publickey,password debug1: Next authentication method: publickey debug1: Will attempt key: /home/ubuntu/.ssh/id_rsa debug1: Will attempt key: /home/ubuntu/.ssh/id_ecdsa debug1: Will attempt key: /home/ubuntu/.ssh/id_ecdsa_sk debug1: Will attempt key: /home/ubuntu/.ssh/id_ed25519 debug1: Will attempt key: /home/ubuntu/.ssh/id_ed25519_sk debug1: Will attempt key: /home/ubuntu/.ssh/id_xmss debug1: Will attempt key: /home/ubuntu/.ssh/id_dsa debug1: Trying private key: /home/ubuntu/.ssh/id_rsa debug1: Trying private key: /home/ubuntu/.ssh/id_ecdsa debug1: Trying private key: /home/ubuntu/.ssh/id_ecdsa_sk debug1: Trying private key: /home/ubuntu/.ssh/id_ed25519 debug1: Trying private key: /home/ubuntu/.ssh/id_ed25519_sk debug1: Trying private key: /home/ubuntu/.ssh/id_xmss debug1: Trying private key: /home/ubuntu/.ssh/id_dsa debug1: Next authentication method: password ubuntu@43.153.66.149's password: Authenticated to 43.153.66.149 ([43.153.66.149]:22) using "password". debug1: Remote connections from LOCALHOST:13306 forwarded to local address 127.0.0.1:3306 debug1: Remote connections from LOCALHOST:18088 forwarded to local address 127.0.0.1:8088 debug1: ssh_init_forwarding: expecting replies for 1 forwards debug1: Requesting no-more-sessions@openssh.com 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 /home/ubuntu/.ssh/known_hosts for 43.153.66.149 / (none) debug1: client_input_hostkeys: searching /home/ubuntu/.ssh/known_hosts2 for 43.153.66.149 / (none) debug1: client_input_hostkeys: hostkeys file /home/ubuntu/.ssh/known_hosts2 does not exist debug1: Remote: Forwarding listen address "localhost" overridden by server GatewayPorts debug1: remote forward success for: listen 13306, connect 127.0.0.1:3306 debug1: forwarding_success: all expected forwarding replies received debug1: Remote: Forwarding listen address "localhost" overridden by server GatewayPorts debug1: remote forward success for: listen 18088, connect 127.0.0.1:8088 Learned new hostkey: RSA SHA256:bMnW71Qezpmj4tukHMhu0x0VpvJieee1wdgc60q2EYQ Learned new hostkey: ECDSA SHA256:S6pP7Ec/rv08+KrvN0RqH8YIG3kkN5luqKxKJ69NkJE Adding new key for 43.153.66.149 to /home/ubuntu/.ssh/known_hosts: ssh-rsa SHA256:bMnW71Qezpmj4tukHMhu0x0VpvJieee1wdgc60q2EYQ Adding new key for 43.153.66.149 to /home/ubuntu/.ssh/known_hosts: ecdsa-sha2-nistp256 SHA256:S6pP7Ec/rv08+KrvN0RqH8YIG3kkN5luqKxKJ69NkJE debug1: update_known_hosts: known hosts file /home/ubuntu/.ssh/known_hosts2 does not exist debug1: pledge: network debug1: client_input_global_request: rtype keepalive@openssh.com want_reply 1 debug1: client_input_global_request: rtype keepalive@openssh.com want_reply 1 debug1: client_input_global_request: rtype keepalive@openssh.com want_reply 1 debug1: client_input_global_request: rtype keepalive@openssh.com want_reply 1
最新发布
11-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值