• Lv0
    粉丝0

积分0 / 贡献0

提问1答案被采纳0文章0

作者动态

    OpenHarmony移植了openssh一直连接不上

    八月 显示全部楼层 发表于 2024-10-23 10:31:34
    OpenHarmony移植了ssh之后作为server端连接不上,密钥登陆时已经验证成功了,但client端会直接退出,有大佬知道原因吗

    client端日志:

    ```
    inno@inno-PC:~$ ssh -v root@100.58.20.99 -p 20000
    OpenSSH_7.9p1 Uos-deepin1+sign UOS_Desktop_104*, OpenSSL 1.1.1d  10 Sep 2019
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 19: Applying options for *
    debug1: Connecting to 100.58.20.99 [100.58.20.99] port 20000.
    debug1: Connection established.
    debug1: identity file /home/inno/.ssh/id_rsa type 0
    debug1: identity file /home/inno/.ssh/id_rsa-cert type -1
    debug1: identity file /home/inno/.ssh/id_dsa type -1
    debug1: identity file /home/inno/.ssh/id_dsa-cert type -1
    debug1: identity file /home/inno/.ssh/id_ecdsa type -1
    debug1: identity file /home/inno/.ssh/id_ecdsa-cert type -1
    debug1: identity file /home/inno/.ssh/id_ed25519 type -1
    debug1: identity file /home/inno/.ssh/id_ed25519-cert type -1
    debug1: identity file /home/inno/.ssh/id_xmss type -1
    debug1: identity file /home/inno/.ssh/id_xmss-cert type -1
    debug1: Local version string SSH-2.0-OpenSSH_7.9p1 Uos-deepin1+sign UOS_Desktop_104*
    debug1: Remote protocol version 2.0, remote software version OpenSSH_9.6
    debug1: match: OpenSSH_9.6 pat OpenSSH* compat 0x04000000
    debug1: Authenticating to 100.58.20.99:20000 as 'root'
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: algorithm: curve25519-sha256
    debug1: kex: host key algorithm: rsa-sha2-512
    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: Server host key: ssh-rsa SHA256:M/d7toR5j9Wqw46B3WiCi9iPI1QsaHS+x1+mn/f4zAg
    debug1: Host '[100.58.20.99]:20000' is known and matches the RSA host key.
    debug1: Found key in /home/inno/.ssh/known_hosts:2
    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: Will attempt key: /home/inno/.ssh/id_rsa RSA SHA256:crt1S5/dgwmQKK2slQnHMgiX6yz9BYfbm3mHSQMWVOs
    debug1: Will attempt key: /home/inno/.ssh/id_dsa
    debug1: Will attempt key: /home/inno/.ssh/id_ecdsa
    debug1: Will attempt key: /home/inno/.ssh/id_ed25519
    debug1: Will attempt key: /home/inno/.ssh/id_xmss
    debug1: SSH2_MSG_EXT_INFO received
    debug1: kex_input_ext_info: 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_input_ext_info: publickey-hostbound@openssh.com (unrecognised)
    debug1: kex_input_ext_info: ping@openssh.com (unrecognised)
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue: publickey,password,keyboard-interactive
    debug1: Next authentication method: publickey
    debug1: Offering public key: /home/inno/.ssh/id_rsa RSA SHA256:crt1S5/dgwmQKK2slQnHMgiX6yz9BYfbm3mHSQMWVOs
    debug1: Server accepts key: /home/inno/.ssh/id_rsa RSA SHA256:crt1S5/dgwmQKK2slQnHMgiX6yz9BYfbm3mHSQMWVOs
    debug1: Authentication succeeded (publickey).
    Authenticated to 100.58.20.99 ([100.58.20.99]:20000).
    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: Remote: /.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
    debug1: Remote: /.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
    debug1: Sending environment.
    debug1: permanently_set_uid: 0/0
    debug1: [zbbbbbb] old_gid=0 old_uid=0 pw->pw_gid=0 pw->pw_gid=0 getgid=0 getuid=0
    Environment:
      USER=root
      LOGNAME=root
      HOME=
      PATH=/usr/bin:/bin:/usr/sbin:/sbin:/home/inno/workspace/tpc_c_cplusplus/lycium/usr/openssh-portable/arm64-v8a/bin
      MAIL=/var/mail/root
      SHELL=/bin/false
      TERM=xterm
      SSH_CLIENT=100.58.30.223 56068 20000
      SSH_CONNECTION=100.58.30.223 56068 100.58.20.99 20000
      SSH_TTY=/dev/pts/1
    Could not chdir to home directory : No such file or directory
    usr/bin/acpi usr/bin/arch usr/bin/ascii usr/bin/base64 usr/bin/basename
    bin/blkid sbin/blockdev usr/bin/bunzip2 usr/bin/bzcat usr/bin/cal
    bin/cat usr/bin/catv bin/chattr bin/chgrp bin/chmod bin/chown usr/sbin/chroot
    usr/bin/chrt usr/bin/chvt bin/cksum usr/bin/clear usr/bin/cmp usr/bin/comm
    usr/bin/count bin/cp bin/cpio bin/crc32 usr/bin/cut bin/date usr/bin/dd
    usr/bin/devmem sbin/df usr/bin/dirname bin/dmesg bin/dnsdomainname
    bin/dos2unix usr/bin/du bin/echo bin/egrep usr/bin/eject usr/bin/env
    usr/bin/expand usr/bin/factor usr/bin/fallocate bin/false bin/fgrep
    usr/bin/file usr/bin/find usr/bin/flock usr/bin/fmt usr/bin/free sbin/freeramdisk
    usr/sbin/fsfreeze bin/fstype bin/fsync usr/bin/ftpget usr/bin/ftpput
    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
    usr/bin/getconf sbin/getty bin/grep usr/bin/groups usr/bin/gunzip
    usr/bin/gzip sbin/halt usr/bin/head bin/help usr/bin/hexedit bin/hostname
    sbin/hwclock usr/bin/i2cdetect usr/bin/i2cdump usr/bin/i2cget usr/bin/i2cset
    usr/bin/iconv usr/bin/id sbin/ifconfig usr/bin/inotifyd sbin/insmod
    usr/bin/install usr/bin/ionice usr/bin/iorenice usr/bin/iotop bin/kill
    usr/bin/killall sbin/killall5 usr/bin/link bin/ln usr/bin/logger bin/login
    usr/bin/logname sbin/losetup bin/ls bin/lsattr sbin/lsmod usr/bin/lsof
    usr/bin/lspci usr/bin/lsusb usr/bin/makedevs usr/bin/mcookie usr/bin/md5sum
    usr/bin/mdev usr/bin/microcom usr/bin/mix bin/mkdir usr/bin/mkfifo
    bin/mknod usr/bin/mkpasswd sbin/mkswap bin/mktemp sbin/modinfo bin/mount
    bin/mountpoint bin/mv usr/bin/nbd-client bin/netstat bin/nice usr/bin/nl
    usr/bin/nohup usr/bin/nproc usr/bin/nsenter usr/bin/od sbin/oneit
    sbin/partprobe usr/bin/passwd usr/bin/paste usr/bin/patch usr/bin/pgrep
    bin/pidof usr/bin/ping usr/bin/ping6 sbin/pivot_root usr/bin/pkill
    usr/bin/pmap sbin/poweroff bin/printenv usr/bin/printf usr/bin/prlimit
    bin/ps bin/pwd usr/bin/pwdx bin/readahead usr/bin/readlink usr/bin/realpath
    sbin/reboot usr/bin/renice usr/bin/reset usr/bin/rev usr/sbin/rfkill
    bin/rm bin/rmdir sbin/rmmod bin/route bin/sed usr/sbin/sendevent usr/bin/seq
    usr/bin/setfattr usr/bin/setsid usr/bin/sha1sum usr/bin/shred bin/sleep
    usr/bin/sntp usr/bin/sort usr/bin/split bin/stat usr/bin/strings sbin/swapoff
    sbin/swapon sbin/switch_root bin/sync sbin/sysctl usr/bin/tac usr/bin/tail
    usr/bin/tar usr/bin/taskset usr/bin/tee usr/bin/telnetd usr/bin/test
    usr/bin/time usr/bin/timeout usr/bin/top bin/touch bin/true usr/bin/truncate
    usr/bin/tty usr/bin/tunctl usr/bin/ulimit bin/umount bin/uname usr/bin/uniq
    bin/unix2dos usr/bin/unlink usr/bin/unshare usr/bin/uptime bin/usleep
    usr/bin/uudecode usr/bin/uuencode usr/bin/uuidgen sbin/vconfig bin/vmstat
    usr/bin/w usr/bin/watch usr/bin/wc usr/bin/which usr/bin/who usr/bin/whoami
    usr/bin/xargs usr/bin/xxd usr/bin/yes usr/bin/zcat
    debug1: channel 0: free: client-session, nchannels 1
    Connection to 100.58.20.99 closed.
    Transferred: sent 3008, received 7168 bytes, in 0.1 seconds
    Bytes per second: sent 60026.6, received 143042.2
    debug1: Exit status 0
    ```

    server端日志:

    ```
    # `pwd`/sshd -f sshd_config -h /.ssh/id_rsa -d
    debug1: sshd version OpenSSH_9.6, OpenSSL 1.1.1u  30 May 2023
    debug1: private host key #0: ssh-rsa SHA256:M/d7toR5j9Wqw46B3WiCi9iPI1QsaHS+x1+mn/f4zAg
    debug1: rexec_argv[0]='/data/ssh/debug/usr/openssh-portable/arm64-v8a/sbin/sshd'
    debug1: rexec_argv[1]='-f'
    debug1: rexec_argv[2]='sshd_config'
    debug1: rexec_argv[3]='-h'
    debug1: rexec_argv[4]='/.ssh/id_rsa'
    debug1: rexec_argv[5]='-d'
    debug1: Bind to port 20000 on 0.0.0.0.
    Server listening on 0.0.0.0 port 20000.
    debug1: Bind to port 20000 on ::.
    Server listening on :: port 20000.
    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.6, OpenSSL 1.1.1u  30 May 2023
    debug1: private host key #0: ssh-rsa SHA256:M/d7toR5j9Wqw46B3WiCi9iPI1QsaHS+x1+mn/f4zAg
    debug1: inetd sockets after dupping: 3, 3
    Connection from 100.58.30.223 port 56068 on 100.58.20.99 port 20000
    debug1: Local version string SSH-2.0-OpenSSH_9.6
    debug1: Remote protocol version 2.0, remote software version OpenSSH_7.9p1 Uos-deepin1+sign UO
    S_Desktop_104*
    debug1: compat_banner: match: OpenSSH_7.9p1 Uos-deepin1+sign UOS_Desktop_104* pat OpenSSH* com
    pat 0x04000000
    debug1: permanently_set_uid: 12005/12001 [preauth]
    debug1: [zbbbbbb] old_gid=0 old_uid=0 pw->pw_gid=12001 pw->pw_gid=12005 getgid=12001 getuid=12
    005 [preauth]
    debug1: list_hostkey_types: rsa-sha2-512,rsa-sha2-256 [preauth]
    debug1: SSH2_MSG_KEXINIT sent [preauth]
    debug1: SSH2_MSG_KEXINIT received [preauth]
    debug1: kex: algorithm: curve25519-sha256 [preauth]
    debug1: kex: host key algorithm: rsa-sha2-512 [preauth]
    debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression:
    none [preauth]
    debug1: kex: server->client cipher: chacha20-poly1305@openssh.com 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 root service ssh-connection method none [preauth]
    debug1: attempt 0 failures 0 [preauth]
    debug1: userauth-request for user root service ssh-connection method publickey [preauth]
    debug1: attempt 1 failures 0 [preauth]
    debug1: userauth_pubkey: publickey test pkalg rsa-sha2-512 pkblob RSA SHA256:crt1S5/dgwmQKK2sl
    QnHMgiX6yz9BYfbm3mHSQMWVOs [preauth]
    debug1: temporarily_use_uid: 0/0 (e=0/0)
    debug1: trying public key file /.ssh/authorized_keys
    debug1: fd 4 clearing O_NONBLOCK
    debug1: /.ssh/authorized_keys:1: matching key found: RSA SHA256:crt1S5/dgwmQKK2slQnHMgiX6yz9BY
    fbm3mHSQMWVOs
    debug1: /.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11
    -forwarding
    Accepted key RSA SHA256:crt1S5/dgwmQKK2slQnHMgiX6yz9BYfbm3mHSQMWVOs found at /.ssh/authorized_
    keys:1
    debug1: restore_uid: 0/0
    Postponed publickey for root from 100.58.30.223 port 56068 ssh2 [preauth]
    debug1: userauth-request for user root service ssh-connection method publickey [preauth]
    debug1: attempt 2 failures 0 [preauth]
    debug1: temporarily_use_uid: 0/0 (e=0/0)
    debug1: trying public key file /.ssh/authorized_keys
    debug1: fd 4 clearing O_NONBLOCK
    debug1: /.ssh/authorized_keys:1: matching key found: RSA SHA256:crt1S5/dgwmQKK2slQnHMgiX6yz9BY
    fbm3mHSQMWVOs
    debug1: /.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11
    -forwarding
    Accepted key RSA SHA256:crt1S5/dgwmQKK2slQnHMgiX6yz9BYfbm3mHSQMWVOs found at /.ssh/authorized_
    keys:1
    debug1: restore_uid: 0/0
    debug1: auth_activate_options: setting new authentication options
    Accepted publickey for root from 100.58.30.223 port 56068 ssh2: RSA SHA256:crt1S5/dgwmQKK2slQn
    HMgiX6yz9BYfbm3mHSQMWVOs
    debug1: monitor_child_preauth: user root authenticated by privileged process
    debug1: auth_activate_options: setting new authentication options [preauth]
    debug1: monitor_read_log: child log fd closed
    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 no-more-sessions@openssh.com 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_pty_req: session 0 alloc /dev/pts/1
    debug1: pty_setowner: no tty group
    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 root from 100.58.30.223 port 56068 id 0
    debug1: Setting controlling tty using TIOCSCTTY.
    debug1: Received SIGCHLD.
    debug1: session_by_pid: pid 23369
    debug1: session_exit_message: session 0 channel 0 pid 23369 exit 0
    debug1: session_exit_message: release channel 0
    debug1: session_pty_cleanup2: session 0 release /dev/pts/1
    Received disconnect from 100.58.30.223 port 56068:11: disconnected by user
    Disconnected from user root 100.58.30.223 port 56068
    debug1: do_cleanup
    ```

    您尚未登录,无法参与评论,登录后可以:
    参与开源共建问题交流
    认同或收藏高质量问答
    获取积分成为开源共建先驱

    精彩评论2

    八月

    沙发 发表于 2024-10-23 13:34:30
    求助大佬

    Hazel

    板凳 发表于 2024-10-25 11:03:38
    /etc/passwd和/etc/group有没有修改
    passwd:
    root:x:0:0::/root:/bin/sh
    sshd:x:0:0rivilege-separated SSH:/var/empty/sshd:/sbin/nologin

    group:
    sshd:x:74:

    Copyright   ©2023  OpenHarmony开发者论坛  京ICP备2020036654号-3 |技术支持 Discuz!

    返回顶部