1

I have the following line in sshd_config to make a transcript of every session:

ForceCommand script -q "/transcripts/test_transcript" -c "{SSH_ORIGINAL_COMMAND:=bash}"

SSH works as expected but when I try to SCP, it hangs at this point:

$ scp -v user@localhost:~/test .

# Lots of debug lines describing key exchange and auth

debug1: Sending command: scp -v -f ~/test

If I remove the line with ForceCommand from sshd_config, SCP works fine.

I assume this is not an uncommon pattern for making session transcripts and tried searching for a solution to this problem. As you can imagine it can be hard to find links that mention script, the utility to make a typescript of a terminal session from util-linux package, and not some other script.

anx
  • 6,875
  • 4
  • 22
  • 45
Max Mikhaylov
  • 171
  • 1
  • 1
  • 6
  • *OpenSSH* devs [have long considered `scp` *outdated, inflexible and not readily fixed*](https://www.openssh.com/txt/release-8.0) so you might just want save yourself the effort of fixing all the edge cases. *sftp* and *rsync* have fewer unexpected shell interactions. – anx Dec 05 '20 at 05:31
  • Do you really need to log the whole session? Or is it sufficient to just log what commands the user executed? – Michael Hampton Dec 05 '20 at 13:53
  • @MichaelHampton I am open to looking at an alternative approach. What do you suggest? – Max Mikhaylov Dec 07 '20 at 16:06
  • 2
    You can try [tlog](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/recording_sessions/index) session recording if your distro supports it, or use the audit system to [log all commands that users run](https://serverfault.com/a/1036183/126632) – Michael Hampton Dec 07 '20 at 16:18
  • @anx Just tried using both sftp and rsync. Similar issues. – Max Mikhaylov Dec 07 '20 at 17:05

0 Answers0