Scp: connection closed

Hey there, I have encountered an issue that i can access to a remote host using ssh, but i can’t send file to that deveice by using ssh, after upgrading the latest system version recently. And the remote device has not been changed recently also.

What else i should offer?

LSB Version:    n/a
Distributor ID: ManjaroLinux
Description:    Manjaro Linux
Release:        21.2.6
Codename:       Qonos
scp root@cable:/tmp/update_pack ./                                                                                                                                                                             
scp: Connection closed
● sshd.service - OpenSSH Daemon
     Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: disabled)
     Active: active (running) since Mon 2022-06-06 08:53:48 CST; 3h 4min ago
   Main PID: 729 (sshd)
      Tasks: 1 (limit: 37801)
     Memory: 4.2M
        CPU: 423ms
     CGroup: /system.slice/sshd.service
             └─ 729 "sshd: /usr/bin/sshd -D [listener] 0 of 10-100 startups"

Jun 06 09:48:13 yougaopeng-Manjaro sshd[20260]: pam_systemd_home(sshd:account): systemd-homed is not available: Unit dbus-org.freedesktop.home1.service not found.
Jun 06 09:48:13 yougaopeng-Manjaro sshd[20260]: Accepted publickey for yougaopeng from 192.168.2.184 port 36724 ssh2: RSA SHA256:WxkFQ0IzSb7VKokTDIBGIQFagYHvyznCwSEvlXBKlu8
Jun 06 09:48:13 yougaopeng-Manjaro sshd[20260]: pam_unix(sshd:session): session opened for user yougaopeng(uid=1000) by (uid=0)
Jun 06 09:48:13 yougaopeng-Manjaro sshd[20260]: pam_env(sshd:session): deprecated reading of user environment enabled
Jun 06 09:48:13 yougaopeng-Manjaro sshd[20260]: pam_unix(sshd:session): session closed for user yougaopeng
Jun 06 09:48:30 yougaopeng-Manjaro sshd[20293]: pam_systemd_home(sshd:account): systemd-homed is not available: Unit dbus-org.freedesktop.home1.service not found.
Jun 06 09:48:30 yougaopeng-Manjaro sshd[20293]: Accepted publickey for yougaopeng from 192.168.2.184 port 36726 ssh2: RSA SHA256:WxkFQ0IzSb7VKokTDIBGIQFagYHvyznCwSEvlXBKlu8
Jun 06 09:48:30 yougaopeng-Manjaro sshd[20293]: pam_unix(sshd:session): session opened for user yougaopeng(uid=1000) by (uid=0)
Jun 06 09:48:30 yougaopeng-Manjaro sshd[20293]: pam_env(sshd:session): deprecated reading of user environment enabled
Jun 06 09:48:30 yougaopeng-Manjaro sshd[20293]: pam_unix(sshd:session): session closed for user yougaopeng

Hello @canyue980 :wink:

I guess you should be long enough here to know that pictures of text is a bad practice. Use markdown codeblocks.

This should reveal more info:

scp -v source target
1 Like

thanks for your reply.

scp -v root@cable:/tmp/update_pack ./                                                                                                                                                                          
Executing: program /usr/bin/ssh host cable, user root, command sftp
OpenSSH_9.0p1, OpenSSL 1.1.1o  3 May 2022
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to cable [192.168.254.1] port 22.
debug1: Connection established.
debug1: identity file /home/yougaopeng/.ssh/id_rsa type 0
debug1: identity file /home/yougaopeng/.ssh/id_rsa-cert type -1
debug1: identity file /home/yougaopeng/.ssh/id_ecdsa type -1
debug1: identity file /home/yougaopeng/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/yougaopeng/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/yougaopeng/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/yougaopeng/.ssh/id_ed25519 type -1
debug1: identity file /home/yougaopeng/.ssh/id_ed25519-cert type -1
debug1: identity file /home/yougaopeng/.ssh/id_ed25519_sk type -1
debug1: identity file /home/yougaopeng/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/yougaopeng/.ssh/id_xmss type -1
debug1: identity file /home/yougaopeng/.ssh/id_xmss-cert type -1
debug1: identity file /home/yougaopeng/.ssh/id_dsa type -1
debug1: identity file /home/yougaopeng/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.0
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: compat_banner: match: OpenSSH_7.4 pat OpenSSH_7.4* compat 0x04000006
debug1: Authenticating to cable:22 as 'root'
debug1: load_hostkeys: fopen /home/yougaopeng/.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: curve25519-sha256
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:Omn4QmLNdQyUhlNTvF+iL92GjEvcGbJAWt7QFx5wOmc
debug1: load_hostkeys: fopen /home/yougaopeng/.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 'cable' is known and matches the ED25519 host key.
debug1: Found key in /home/yougaopeng/.ssh/known_hosts:1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/yougaopeng/.ssh/id_rsa RSA SHA256:WxkFQ0IzSb7VKokTDIBGIQFagYHvyznCwSEvlXBKlu8
debug1: Will attempt key: /home/yougaopeng/.ssh/id_ecdsa 
debug1: Will attempt key: /home/yougaopeng/.ssh/id_ecdsa_sk 
debug1: Will attempt key: /home/yougaopeng/.ssh/id_ed25519 
debug1: Will attempt key: /home/yougaopeng/.ssh/id_ed25519_sk 
debug1: Will attempt key: /home/yougaopeng/.ssh/id_xmss 
debug1: Will attempt key: /home/yougaopeng/.ssh/id_dsa 
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
Authenticated to cable ([192.168.254.1]:22) using "none".
debug1: channel 0: new [client-session]
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/yougaopeng/.ssh/known_hosts for cable / (none)
debug1: client_input_hostkeys: searching /home/yougaopeng/.ssh/known_hosts2 for cable / (none)
debug1: client_input_hostkeys: hostkeys file /home/yougaopeng/.ssh/known_hosts2 does not exist
debug1: Sending subsystem: sftp
debug1: client_global_hostkeys_private_confirm: server used untrusted RSA signature algorithm ssh-rsa for key 0, disregarding
debug1: update_known_hosts: known hosts file /home/yougaopeng/.ssh/known_hosts2 does not exist
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
scp: Connection closed
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2180, received 2816 bytes, in 0.0 seconds
Bytes per second: sent 53982.5, received 69731.6
debug1: Exit status 127

Are you sure root is allowed on the sshd server? I see you login there as user:

So:

scp yougaopeng@cable:/tmp/update_pack ./ 

sorry for the ambiguity, I’m trying to copy files from my manjaro(yougaopeng) system to another linux device(root).
I am allowed to ssh to the device as root:

ssh root@cable                                                                                                                                                                                                 
Last login: Thu Mar 25 03:27:57 2021 from 192.168.254.254
root@ilife:/var/volatile/tmp#

Gotcha.

I see the problem now and it seems not to be Manjaro’s fault.

It tries to send a file using sftp:

But failed and exit with:

127 → Not found.

In this context it means your server has no sftp enabled or it cannot find the command.

but i can use scp cmd if i roll back to older version using timeshift, without changing any setting in my target device.
so im curious whether there are some settings about ’scp‘ have been changed automaticly.

Well there is still a big version gap. It could happen that changes now affects you. However it is related to sftp subsystem. Maybe the path?

Things change, things get deprecated, etc. When something stops working it’s a good practice to check program’s official release notes/changes.

Read note: SCP and SFTP - ArchWiki

1 Like

There recently was an update to openSSH depricating some older algorythms that are no longer secure enough. It seems that your servers OpenSSH version is still using one of these old versions.

1 Like

Yeah, this too. So for any old unupdatable hardware you have to use additional options like PubkeyAcceptedAlgorithms +ssh-rsa, etc. But his ssh works, so this shouldn’t be an issue, I think.

Thanks for all guys that offer helps! I just found the solution in upper link:

Note: Since OpenSSH 8.8 the scp utility uses the SFTP protocol by default. The -O option must be used to use the legacy SCP protocol.

by using -O option and it works!

scp -O file_name target_dir

and of course you can also add an alias for it in~/.zshrc like this:

alias scp="scp -O"
1 Like

High five yourself in the mirror.

1 Like

Beside marking your own posts as a solution, this (using legacy for everything):

is another wonderful idea.

1 Like

Thanks again for ur patient guidance :grin:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.