LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-17-2024, 01:58 AM   #1
lq_win
Member
 
Registered: Jul 2015
Posts: 66

Rep: Reputation: Disabled
Deny SSH but allow SFTP


Hi all,

We deny ssh access to our server but we want to allow SFTP, as far as I know SFTP uses the same port 22 like SSH, how to deny the SSH but allow the SFTP?
 
Old 04-17-2024, 02:19 AM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,728

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
searching for "allow sftp but not ssh" yields many helpful links. Please review some of those and come back if you have any questions.
 
1 members found this post helpful.
Old 04-17-2024, 02:55 AM   #3
lq_win
Member
 
Registered: Jul 2015
Posts: 66

Original Poster
Rep: Reputation: Disabled
I followed the instruction on: https://www.server-world.info/en/not...ux_9&p=ssh&f=5

/etc/ssh/sshd_config

Subsystem sftp internal-sftp

Match Group sftp_users
X11Forwarding no
AllowTcpForwarding no
ChrootDirectory /home
ForceCommand internal-sftp


Include /etc/ssh/ssh_config.d/*.conf

and usermod -aG sftp_users gogo

but user gogo still able to access SSH

what I missed?
 
Old 04-17-2024, 03:10 AM   #4
lq_win
Member
 
Registered: Jul 2015
Posts: 66

Original Poster
Rep: Reputation: Disabled
please ignore.. this is my bad!..I did wrong config.
it works now, thank you, but how about if we also want to give them access to other folder like /var/www/html and /home/public?

need your advice/

thanks

Last edited by lq_win; 04-17-2024 at 03:19 AM.
 
Old 04-17-2024, 03:32 AM   #5
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,313
Blog Entries: 3

Rep: Reputation: 3723Reputation: 3723Reputation: 3723Reputation: 3723Reputation: 3723Reputation: 3723Reputation: 3723Reputation: 3723Reputation: 3723Reputation: 3723Reputation: 3723
You might consider a bind mount of the other directories into the accounts' chroot directories.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
restrict sftp but allow ssh udittomar52 Linux - Newbie 2 06-15-2023 12:07 AM
Can I allow SFTP for ANY , but SSH for some IP address davidklc Linux - Security 6 07-23-2010 05:57 AM
Apache2 > "order allow,deny" to allow subdirectories cbonar Linux - Server 13 10-27-2007 03:08 PM
Access allow and deny to APACHE & SSH longnam Solaris / OpenSolaris 5 03-02-2007 07:59 AM
How to setup a host.deny and host.allow for SSH? explorer1979 Linux - Security 2 01-31-2005 05:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration