• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Friday, May 9, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System CentOS

Setup SFTP-only User Accounts on CentOS 7

How VPS by How VPS
October 1, 2019
in CentOS
0
0
SHARES
14
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Prerequisites
  2. Step 1: Create a dedicated sFTP group and a dedicated sFTP user
  3. Step 2: Modify the configuration of the sshd service
  4. Step 3: Create a dedicated directory for the sFTP-only user
  5. Step 4: Create more sFTP-only users
  6. Want to contribute?


On certain occasions, a Systems Administrator may need to create a user account and restrict their access to only manage their own files via sFTP, but not be able to login to the system using any other means. The solution introduced in this article will show you how to accomplish this task.

Prerequisites

To get hands-on experience, you need to deploy a Vultr CentOS 7 x64 server instance. Please note that the instructions for other Linux distributions may be different.

Additionally, all commands in this article are suitable for the root; as such, you would need sudo privileges if you are using a non-root user.

Step 1: Create a dedicated sFTP group and a dedicated sFTP user

groupadd sftpusers
useradd -g sftpusers -s /sbin/nologin user1
passwd user1

Here, the group sftpusers is a dedicated sFTP group, the user user1 is a dedicated sFTP user which is forbidden to log in using SSH.

Step 2: Modify the configuration of the sshd service

Open the configuration file of the sshd service:

vi /etc/ssh/sshd_config

Find the line:

Subsystem sftp /usr/libexec/openssh/sftp-server

Replace it with:

Subsystem sftp internal-sftp

Append the following lines to the end of the file. The group name sftpusers should be the same as the one you specified earlier.

Match Group sftpusers
X11Forwarding no
AllowTcpForwarding no
ChrootDirectory %h
ForceCommand internal-sftp

Save and quit:

:wq

Restart the sshd service to put your changes into effect.

systemctl restart sshd.service

Step 3: Create a dedicated directory for the sFTP-only user

You need to specify a directory for the sFTP-only user and make sure that this user can only play around in this directory:

chown -R root /home/user1
chmod -R 755 /home/user1
mkdir /home/user1/files
chown user1. /home/user1/files

Now, the user user1 can only upload and/or download files in the directory /home/user1/files, he or she can never touch other users’ files.

Step 4: Create more sFTP-only users

If you need more sFTP-only users, you can create them in the same fashion:

useradd -g sftpusers -s /sbin/nologin user2
passwd user2
chown -R root /home/user2
chmod -R 755 /home/user2
mkdir /home/user2/files
chown user2. /home/user2/files

That’s it. Each user account created in this fashion will be denied if you use it to log in the system. These user accounts can be used only in sFTP programs.

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
Previous Post

How to Install Shopware CE on CentOS 7

Next Post

How to Install Snipe-IT on CentOS 7

Next Post

How to Install Snipe-IT on CentOS 7

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet