coolsnowwolf / lede

Lean's LEDE source
Other
29.56k stars 19.51k forks source link

发现ssh 拒绝连接,web UI正常登录 #10332

Closed yuhongwei380 closed 1 year ago

yuhongwei380 commented 1 year ago

反馈bug/问题模板,提建议请删除

1.关于你要提交的问题

ssh相关问题 Q:是否搜索了issue (使用 "x" 选择)

2. 详细叙述

(1) 具体问题

A:近期编译固件发现新版本的固件编译出来,我qm import 到pve上,发现op发现ssh 拒绝连接,web UI正常登录;ssh -vvv localhost 也是 拒绝连接;

(2) 路由器型号和固件版本

A:X86版本;虚拟机,5.15.58

(3) 详细日志

A:ssh连接,提示拒绝连接;

zhangguanzhang commented 1 year ago

你都有pve了,pve的console进去看看日志和系统日志不行吗,以及consol里ssh -vvv localhost试试

yuhongwei380 commented 1 year ago

目前发现是xshell 无法ssh 连接到自编译新版本 的问题,用cmd 和 terminal可以ssh访问;xshell 可以正常ssh 到5.15.28 版本的;case 先关了;我自己再排查看看吧

zhangguanzhang commented 1 year ago

应该是client 的ssh的密钥算法和op里的不匹配

yuhongwei380 commented 1 year ago

害,我也不知道哪儿出问题了;新编了一个版本,发现又没法 cmd 和terminal访问了;感觉是网络层面的问题或者是ssh 这边的问题,之前遇到了centos8 ssh 无法ssh,是因为ipqos 影响到。我们是访问ipsec 对端的 op;

zhangguanzhang commented 1 year ago

你找个局域网的大型linux,或者你的pve,ssh -vvvv 看下调试信息

yuhongwei380 commented 1 year ago

root@OpenWrt:~# ssh localhost ssh: Connection to root@localhost:22 exited: Connect failed: Connection refused

yuhongwei380 commented 1 year ago

大局域网内是可以ssh 的,跨ipsec-vpn的访问就有问题了;对端也有和OP一样网段的linux,可以正常ssh到; 同局域网,ssh调试信息如下,IP我隐去了; [vesoft@localhost ~]$ ssh -vvv root@192.168.15.x 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 * debug2: resolving "192.168.15.252" port 22 debug2: ssh_connect_direct: needpriv 0 debug1: Connecting to 192.168.15.x [192.168.15.x] port 22. debug1: Connection established. debug1: identity file /home/vesoft/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /home/vesoft/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/vesoft/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/vesoft/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/vesoft/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/vesoft/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/vesoft/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/vesoft/.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 dropbear debug1: no match: dropbear debug2: fd 3 setting O_NONBLOCK debug1: Authenticating to 192.168.15.x:22 as 'root' debug3: hostkeys_foreach: reading file "/home/vesoft/.ssh/known_hosts" debug3: record_hostkey: found key type ED25519 in file /home/vesoft/.ssh/known_hosts:126 debug3: load_hostkeys: loaded 1 keys from 192.168.15.x debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-ed25519-cert-v01@openssh.com,ssh-ed25519 debug3: send packet: type 20 debug1: SSH2_MSG_KEXINIT sent debug3: receive packet: type 20 debug1: SSH2_MSG_KEXINIT received debug2: local client KEXINIT proposal debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,ext-info-c debug2: host key algorithms: ssh-ed25519-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: compression ctos: none,zlib@openssh.com,zlib debug2: compression stoc: none,zlib@openssh.com,zlib debug2: languages ctos: debug2: languages stoc: debug2: first_kex_follows 0 debug2: reserved 0 debug2: peer server KEXINIT proposal debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,kexguess2@matt.ucc.asn.au debug2: host key algorithms: ssh-ed25519,rsa-sha2-256,ssh-rsa debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes256-ctr debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes256-ctr debug2: MACs ctos: hmac-sha1,hmac-sha2-256 debug2: MACs stoc: hmac-sha1,hmac-sha2-256 debug2: compression ctos: none debug2: compression stoc: none debug2: languages ctos: debug2: languages stoc: debug2: first_kex_follows 0 debug2: reserved 0 debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ssh-ed25519 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: compression: none debug1: kex: curve25519-sha256 need=64 dh_need=64 debug1: kex: curve25519-sha256 need=64 dh_need=64 debug3: send packet: type 30 debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug3: receive packet: type 31 debug1: Server host key: ssh-ed25519 SHA256:yjlNIXsr1Np9BdApwM5guZ5DaHuf5JcMGWrOZu+kdJg debug3: hostkeys_foreach: reading file "/home/vesoft/.ssh/known_hosts" debug3: record_hostkey: found key type ED25519 in file /home/vesoft/.ssh/known_hosts:126 debug3: load_hostkeys: loaded 1 keys from 192.168.15.x debug1: Host '192.168.15.x' is known and matches the ED25519 host key. debug1: Found key in /home/vesoft/.ssh/known_hosts:126 debug3: send packet: type 21 debug2: set_newkeys: mode 1 debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug3: receive packet: type 21 debug1: SSH2_MSG_NEWKEYS received debug2: set_newkeys: mode 0 debug1: rekey after 134217728 blocks debug2: key: /home/vesoft/.ssh/id_rsa (0x55649fa95ed0) debug2: key: /home/vesoft/.ssh/id_dsa ((nil)) debug2: key: /home/vesoft/.ssh/id_ecdsa ((nil)) debug2: key: /home/vesoft/.ssh/id_ed25519 ((nil)) debug3: send packet: type 5 debug3: receive packet: type 7 debug1: SSH2_MSG_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=ssh-ed25519,sk-ssh-ed25519@openssh.com,rsa-sha2-256,ssh-rsa debug3: receive packet: type 6 debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received debug3: send packet: type 50 debug3: receive packet: type 51 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/vesoft/.ssh/id_rsa debug3: send_pubkey_test debug3: send packet: type 50 debug2: we sent a publickey packet, wait for reply debug3: receive packet: type 51 debug1: Authentications that can continue: publickey,password debug1: Trying private key: /home/vesoft/.ssh/id_dsa debug3: no such identity: /home/vesoft/.ssh/id_dsa: No such file or directory debug1: Trying private key: /home/vesoft/.ssh/id_ecdsa debug3: no such identity: /home/vesoft/.ssh/id_ecdsa: No such file or directory debug1: Trying private key: /home/vesoft/.ssh/id_ed25519 debug3: no such identity: /home/vesoft/.ssh/id_ed25519: No such file or directory debug2: we did not send a packet, disable method debug3: authmethod_lookup password debug3: remaining preferred: ,password debug3: authmethod_is_enabled password debug1: Next authentication method: password root@192.168.15.x's password: debug3: send packet: type 50 debug2: we sent a password packet, wait for reply debug3: receive packet: type 52 debug1: Authentication succeeded (password). Authenticated to 192.168.15.x ([192.168.15.x]:22). debug1: channel 0: new [client-session] debug3: ssh_session2_open: channel_new: 0 debug2: channel 0: send open debug3: send packet: type 90 debug1: Entering interactive session. debug1: pledge: network debug3: receive packet: type 91 debug2: callback start debug2: fd 3 setting TCP_NODELAY debug3: ssh_packet_set_tos: set IP_TOS 0x10 debug2: client_session2_setup: id 0 debug2: channel 0: request pty-req confirm 1 debug3: send packet: type 98 debug1: Sending environment. debug3: Ignored env XDG_SESSION_ID debug3: Ignored env HOSTNAME debug3: Ignored env SELINUX_ROLE_REQUESTED debug3: Ignored env TERM debug3: Ignored env SHELL debug3: Ignored env HISTSIZE debug3: Ignored env SSH_CLIENT debug3: Ignored env SELINUX_USE_CURRENT_RANGE debug3: Ignored env SSH_TTY debug3: Ignored env USER debug3: Ignored env LS_COLORS debug3: Ignored env MAIL debug3: Ignored env PATH debug3: Ignored env PWD debug1: Sending env LANG = en_US.UTF-8 debug2: channel 0: request env confirm 0 debug3: send packet: type 98 debug3: Ignored env SELINUX_LEVEL_REQUESTED debug3: Ignored env HISTCONTROL debug3: Ignored env SHLVL debug3: Ignored env HOME debug3: Ignored env LOGNAME debug3: Ignored env SSH_CONNECTION debug3: Ignored env LESSOPEN debug3: Ignored env XDG_RUNTIMEDIR debug3: Ignored env debug2: channel 0: request shell confirm 1 debug3: send packet: type 98 debug2: callback done debug2: channel 0: open confirm rwindow 24576 rmax 32759 debug3: receive packet: type 99 debug2: channel_input_status_confirm: type 99 id 0 debug2: PTY allocation request accepted on channel 0 debug3: receive packet: type 99 debug2: channel_input_status_confirm: type 99 id 0 debug2: shell request accepted on channel 0

zhangguanzhang commented 1 year ago

你这是ipsec 的段冲突了吧。。。,你ssh的不是你的op,最简单就是你curl下你op的web或者telnet op的tcp端口,你在op上抓包

yuhongwei380 commented 1 year ago

ispec 段没冲突的哈;我是用的同局域网的ssh 到这台15.X的OP上,-vvv打印信息; 你说的是 curl op的 web地址;然后我op tcpdump 抓包是吗

yuhongwei380 commented 1 year ago

image

zhangguanzhang commented 1 year ago

通过ipsec测下看看

yuhongwei380 commented 1 year ago

我贴的两个图,上面那个图是端A-OP 的抓包,下面的那个图 是ipsec 的另外一端B(我的主机wsl)curl 的op 的web地址,本身就是通过ipsec-vpn了

yuhongwei380 commented 1 year ago

我今天把op的版本降级回我们今年22-3月编译的版本kernel 5.15.28,直接本地就ssh上了 @zhangguanzhang ;我对比了 昨天编译版本的和我3月版本的差别,跟ssh相关的dropbear的版本升级了,我把5.15.28 的dropbear 更新到 2022.82-2 就可以稳定复现无法直接ssh 连接上的故障了。

yuhongwei380 commented 1 year ago

image

zhangguanzhang commented 1 year ago

🤔你用windows 安装个git bash,然后用它的的ssh试试呢

ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa  xxx
yuhongwei380 commented 1 year ago

还是一样的

zhangguanzhang commented 1 year ago
ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa -vvvv  xxx
yuhongwei380 commented 1 year ago

image 目前是这个状态,我感觉还是跟 IPQos 这个有关

yuhongwei380 commented 1 year ago

我看了下dropbear 2022.82版本的release note, 这个版本默认把AF21 作为dscp 的默认;优先级 (tty) 流量现在设置为 AF21“交互式”。 这个问题会导致我的ssh 连接故障的原因; 因为这个问题我们在centos8 的openssh8.0 上也曾遇到了这个故障。

zhangguanzhang commented 1 year ago

上面-vvv的IP_TOS我搜索了下搜不到有用的信息 🤔也就是说搞了个另类的qos吗

yuhongwei380 commented 1 year ago

你搜 IPQos ssh 这种可能会更有相关信息;

yuhongwei380 commented 1 year ago

我到dropbear 那个项目下提出这个问题了,作者表示后续会出一个选项,用来避免这样的情况。https://github.com/mkj/dropbear/issues/193

zhangguanzhang commented 1 year ago

👍很棒