0

I am sure I was SCPing some files TO the server before, but now it does not work in opposite direction.

I'm using:

$ scp -v mysrv:/home/XXX/dir/app.rb app.rb.bak

Authenticated to mysrv ([88.88.111.11]:22) using "publickey". debug1: channel 0: new session [client-session] (inactive timeout: 0) 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: Sending subsystem: sftp debug1: pledge: fork subsystem request failed on channel 0 scp: Connection closed

A.D.
  • 563

1 Answers1

1

Found out in logs on the server that SFTP subsystem can not be found.

# journalctl -f
Jan 24 16:45:43 mysrv sshd[2045]: subsystem request for sftp by user XXX failed, subsystem not found

Don't know how it was disabled, but re-enabling it in config solved the issue. Just uncomment one line..

# nano /etc/ssh/sshd_config 
Subsystem       sftp    /usr/lib/openssh/sftp-server

Don't forget to restart the SSHd.

# systemctl restart ssh

Just for search engine bots - here is the successfull SCP log:

Authenticated to mysrv ([88.88.111.11]:22) using "publickey".
debug1: channel 0: new session [client-session] (inactive timeout: 0)
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: Sending subsystem: sftp
debug1: pledge: fork
scp: debug1: Fetching /home/XXX/dir/app.rb to app.rb.bak

app.rb 100% 38KB 297.3KB/s 00:00
scp: debug1: truncating at 39240 debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: channel 0: free: client-session, nchannels 1 Transferred: sent 3248, received 42336 bytes, in 1.3 seconds Bytes per second: sent 2528.5, received 32958.1 debug1: Exit status 0

A.D.
  • 563
  • 1
    "Don't know how it was disabled" – It's possible it had never been enabled at all. It's possible an update of the client switched the default protocol scp uses from SCP to SFTP. I mean your scp used to use SCP and it worked ("I am sure I was SCPing some files TO the server before") and now it uses SFTP, so only now the Subsystem sftp config of the server matters for your scp. Please see "History, SCP and SFTP" in this answer. – Kamil Maciorowski Jan 24 '24 at 16:28
  • Y, I read your answer. It is possible. I'm just not sure, coz it's outdated (ubuntu 20) server I will get rid of so I thought maybe I disabled some options for security reasons.. Usually I have to enable SFTP subsystem for SCP to work. Anyway I did this just for ppl googling debug msgs. Your answer pops first anyway so they can try - but my macos's SCP does not have -0 :) – A.D. Jan 24 '24 at 17:05