Wednesday, April 7, 2010

SFTP users Restricted access

How to restrict sftp users to do ssh ? here we go

Copy the script to file name sftp-only
##################################
#SOF
#!/bin/sh

if [ "$*" != "-c /usr/libexec/openssh/sftp-server" ]; then
echo .Sorry, ssh access not allowed..;
exit;
fi;
################################

exec /usr/libexec/openssh/sftp-server
#EOF


Please put the Script :: "sftp-only" in /sbin

#chmod 755 /sbin/sftp-only
#usermod -s /sbin/sftp-only username

Example ::

##usermod -s /sbin/sftp-only asad

Then ssh that particular user and you will see follow details .

##############################

[root@Demo-SFTP sbin]# ssh asad@localhost
asad@localhost's password:
Last login: Wed Mar 17 18:20:24 2010 from localhost.localdomain
.Sorry, ssh access not allowed..
Connection to localhost closed.
[root@Demo-SFTP sbin]#

No comments:

Post a Comment