AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1804868
Accepted
mazda
mazda
Asked: 2023-08-19 15:20:38 +0800 CST2023-08-19 15:20:38 +0800 CST 2023-08-19 15:20:38 +0800 CST

如果在连接以太网的情况下打开 WiFi,为什么 SSH 不起作用?

  • 772

我有两台笔记本电脑 [L1、L2] 连接到同一个盒子,都使用 Debian 11:

  • L1:通过以太网连接,无线网卡开启
  • L2:仅通过 WiFi 连接

使用此配置,我无法使用 SSH 将 L1 [客户端] 连接到 L2 [服务器],如果我想使用 SSH,我必须断开 L1 的以太网电缆或关闭 L1 的 WiFi,并且想了解原因:

  • 客户:
    ~$ ip -brief addr
    
      lo               UNKNOWN        127.0.0.1/8 ::1/128
      enp1s0f1         UP             192.168.1.24/24 fe80::id1
      wlp2s0           UP             192.168.1.24/24 fe80::id2
    
    ~$ ssh -vvv [email protected]
    
      OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n  15 Mar 2022
    
      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 *
    
      debug2: resolve_canonicalize: hostname 192.168.1.21 is address
      debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/xxx/.ssh/known_hosts'
      debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/xxx/.ssh/known_hosts2'
      debug2: ssh_connect_direct
    
      debug1: Connecting to 192.168.1.21 [192.168.1.21] port 22.
      debug1: connect to address 192.168.1.21 port 22: No route to host
    
      ssh: connect to host 192.168.1.21 port 22: No route to host
    

  • 服务器:
    ~# /usr/sbin/sshd -d
    
      debug1: sshd version OpenSSH_9.2, OpenSSL 3.0.9 30 May 2023
      debug1: private host key #0: ssh-rsa
      debug1: private host key #1: ecdsa-sha2-nistp256
      debug1: private host key #2: ssh-ed25519
    
      debug1: rexec_argv[0]='/usr/sbin/sshd'
      debug1: rexec_argv[1]='-d'
      debug1: Set /proc/self/oom_score_adj from 0 to -1000
    
      debug1: Bind to port 22 on 0.0.0.0.
      Server listening on 0.0.0.0 port 22.
      debug1: Bind to port 22 on ::.
      Server listening on :: port 22.
    
      debug1: Server will not fork when running in debugging mode.
      debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8
    
      debug1: sshd version OpenSSH_9.2, OpenSSL 3.0.9 30 May 2023
      debug1: private host key #0: ssh-rsa SHA256:
      debug1: private host key #1: ecdsa-sha2-nistp256 SHA256:
      debug1: private host key #2: ssh-ed25519 SHA256:
      debug1: inetd sockets after dupping: 3, 3
    
      Connection from 192.168.1.24 port 36154 on 192.168.1.21 port 22 rdomain ""
    
      debug1: Local version string SSH-2.0-OpenSSH_9.2p1 Debian-2
      debug1: Remote protocol version 2.0, remote software version OpenSSH_8.4p1 Debian-5+deb11u1
      debug1: compat_banner: match: OpenSSH_8.4p1 Debian-5+deb11u1 pat OpenSSH* compat 0x04000000
      debug1: permanently_set_uid: 115/65534 [preauth]
      debug1: list_hostkey_types: rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
      debug1: SSH2_MSG_KEXINIT sent [preauth]
      debug1: SSH2_MSG_KEXINIT received [preauth]
      debug1: kex: algorithm: curve25519-sha256 [preauth]
      debug1: kex: host key algorithm: ecdsa-sha2-nistp256 [preauth]
      debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none [preauth]
      debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none [preauth]
      debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]
      debug1: SSH2_MSG_KEX_ECDH_INIT received [preauth]
      debug1: rekey out after 134217728 blocks [preauth]
      debug1: SSH2_MSG_NEWKEYS sent [preauth]
      debug1: Sending SSH2_MSG_EXT_INFO [preauth]
      debug1: expecting SSH2_MSG_NEWKEYS [preauth]
      debug1: SSH2_MSG_NEWKEYS received [preauth]
      debug1: rekey in after 134217728 blocks [preauth]
      debug1: KEX done [preauth]
      debug1: userauth-request for user xxx  service ssh-connection method none [preauth]
      debug1: attempt 0 failures 0 [preauth]
      debug1: PAM: initializing for "xxx"
      debug1: PAM: setting PAM_RHOST to "192.168.1.24"
      debug1: PAM: setting PAM_TTY to "ssh"
      debug1: userauth_send_banner: sent [preauth]
      debug1: userauth-request for user xxx service ssh-connection method publickey [preauth]
    
      debug1: attempt 1 failures 0 [preauth]
      debug1: userauth_pubkey: publickey test pkalg rsa-sha2-512 pkblob RSA SHA256:[preauth]
      debug1: temporarily_use_uid: 1000/1000 (e=0/0)
      debug1: trying public key file /home/mi/.ssh/authorized_keys
      debug1: fd 4 clearing O_NONBLOCK
      debug1: /home/xxx/.ssh/authorized_keys:1: matching key found: RSA SHA256:
      debug1: /home/xxx/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
    
      Accepted key RSA SHA256: found at /home/xxx/.ssh/authorized_keys:1
      debug1: restore_uid: 0/0
    
      Postponed publickey for xxx from 192.168.1.24 port 36154 ssh2 [preauth]
    
      debug1: userauth-request for user xxx service ssh-connection method publickey [preauth]
      debug1: attempt 2 failures 0 [preauth]
      debug1: temporarily_use_uid: 1000/1000 (e=0/0)
      debug1: trying public key file /home/xxx/.ssh/authorized_keys
      debug1: fd 4 clearing O_NONBLOCK
      debug1: /home/xxx/.ssh/authorized_keys:1: matching key found: RSA SHA256:
      debug1: /home/xxx/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
    
      Accepted key RSA SHA256: found at /home/xxx/.ssh/authorized_keys:1
    
      debug1: restore_uid: 0/0
      debug1: auth_activate_options: setting new authentication options
      debug1: do_pam_account: called
    
      Accepted publickey for xxx from 192.168.1.24 port 36154 ssh2: RSA SHA256:
    
      debug1: monitor_child_preauth: user xxx authenticated by privileged process
      debug1: auth_activate_options: setting new authentication options [preauth]
      debug1: monitor_read_log: child log fd closed
      debug1: PAM: establishing credentials
    
      User child is on pid 2553
    
      debug1: SELinux support disabled
      debug1: PAM: establishing credentials
      debug1: permanently_set_uid: 1000/1000
      debug1: rekey in after 134217728 blocks
      debug1: rekey out after 134217728 blocks
      debug1: ssh_packet_set_postauth: called
      debug1: active: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
      debug1: Entering interactive session for SSH2.
      debug1: server_init_dispatch
      debug1: server_input_channel_open: ctype session rchan 0 win 1048576 max 16384
      debug1: input_session_request
      debug1: channel 0: new session [server-session] (inactive timeout: 0)
      debug1: session_new: session 0
      debug1: session_open: channel 0
      debug1: session_open: session 0: link with channel 0
      debug1: server_input_channel_open: confirm session
      debug1: server_input_global_request: rtype [email protected] want_reply 0
      debug1: server_input_channel_req: channel 0 request pty-req reply 1
      debug1: session_by_channel: session 0 channel 0
      debug1: session_input_channel_req: session 0 req pty-req
      debug1: Allocating pty.
      debug1: session_new: session 0
      debug1: SELinux support disabled
      debug1: session_pty_req: session 0 alloc /dev/pts/1
      debug1: server_input_channel_req: channel 0 request env reply 0
      debug1: session_by_channel: session 0 channel 0
      debug1: session_input_channel_req: session 0 req env
      debug1: server_input_channel_req: channel 0 request shell reply 1
      debug1: session_by_channel: session 0 channel 0
      debug1: session_input_channel_req: session 0 req shell
    
      Starting session: shell on pts/1 for xxx from 192.168.1.24 port 36154 id 0
    
linux
  • 1 1 个回答
  • 96 Views

1 个回答

  • Voted
  1. Best Answer
    dodrg
    2023-08-19T16:34:01+08:002023-08-19T16:34:01+08:00

    通过日志和网络设置更新问题后修改答案:

    在客户端L1,NIC、以太网和WiFi都分配了相同的IP。
    为它们分配不同的IP后,问题就消失了。


    获取调试日志:

    1. 退出任何打开的 SSH 会话
    2. 停止sshd,然后以详细调试方式重新启动它:
      # Get the PID for sshd' and terminate it:
        ps ax | sudo sed -En 's|^\s*([0-9]+)\s.*/usr/sbin/ssh[d].*$|kill \1|pe'
      
      # Verify success (sshd processes should show up):
        ps ax | grep "ssh[d]"
      
      # Start sshd with debug option, then print output to screen and file:
        sudo /usr/sbin/sshd -d | tee your_debug.log
      
      
       # For debug verbosity on the client, call ssh with <-v || -vv || -vvv>:
         # -v: Debug1 || -vv: Debug2 | -vvv: Debug3:
           ssh -v <parameters>
      
    3. 启用调试后,sshd输出到终端并your_debug.log
    • 1

相关问题

  • 如何让我的 Linux 机器看起来像是在运行 Windows?

  • 对于 cp 或 mv,是否有等同于 cd - 的东西?

  • 以 root 身份运行 docker 容器

  • 如何在域和 Linux 活动目录中启用指纹传感器

  • 如何在CentOS 7 中将Ctrl+C 永久更改为Ctrl+K?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve