On a CentOS 7 server, I'd like to configure it such that:
- It accepts SSH connections, like PuTTY
- It denies SCP/SFTP connections, like SCP, WinSCP, and FileZilla
Is such a configuration possible?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityIt wouldn't help you because the user could trivially do:
ssh user@host "cat /path/to/file" > /local/path/to/file
cat /local/path/to/file | ssh user@host "cat - > /path/to/file"
to copy files down and up respectively.
Yes, you can.
To disable sftp, find the line that starts with Subsystem sftp
in the /etc/ssh/sshd_config
file (by default, it's near the very end of the file). Comment it out (put a #
at the beginning of the line) and restart sshd.
SCP has no such configuration, the client scp
program simply expects the remote scp
executable to be in the user's path. So, just delete the scp
binary to disable it. (And then you have to remember to delete it again every time you update your SSH package.)
But, as other people have said, this is not going to stop the users from uploading and downloading files. It just makes it ever-so-slightly more difficult. So, if you're doing this for security reasons, you really need to reconsider.
scp
program can actually use the SFTP protocol internally (and it's going to become the default mode of operation later). You thus have to disable both protocols to actually stop people from using scp
. (It's still pointless when shell access is available.)
echo my stuff>> newfile.sh
.