How to disable the SCP protocol on an SSH server?

Hello everyone, Any idea of how can I turn off the SCP protocol on an SSH server?

Thanks, Jenn

Hello,

By default in Alma Linux 9, the scp command operates over the SFTP protocol rather than the traditional SCP protocol. Even so, you can still force it to use the old SCP protocol by using the -O option. In addition, the sshd service continues to permit connections from clients that rely on the SCP protocol.

To completely disable the use of the SCP protocol, create a file named /etc/ssh/disable_scp by running the following command:

# touch  /etc/ssh/disable_scp

When the file is created, the scp command no longer permits using the -O option to enable the SCP protocol.

On Alma Linux 9, the scp command defaults to using the SFTP protocol, but it is still possible to use the SCP protocol unless it is explicitly disabled; in addition, the sshd service continues to accept connections from clients that use the SCP protocol unless configured otherwise.

On Alma Linux 8, the scp command uses the SCP protocol as the default.

You can confirm that the SCP protocol is disabled on Alma Linux 9 by trying to transfer a file using the -O option.

$ scp -O file localhost:
SCP protocol is forbidden via /etc/ssh/disable_scp

On Alma Linux 8, the scp command does not recognize the -O option and always operates using the SCP protocol.

$ scp file localhost:
SCP protocol is forbidden via /etc/ssh/disable_scp

Cheers :waving_hand: