当前位置:网站首页>Contos 7 set up SFTP to create users, user groups, and delete users
Contos 7 set up SFTP to create users, user groups, and delete users
2022-07-01 19:23:00 【Infinitesimal pawn】
1、 Add new users and set up profiles
# establish sftp System user and disable ssh Sign in
useradd -s /sbin/nologin sftp1
# Set or modify sftp1 Sign in
echo "[email protected]" |passwd --stdin sftp1
# To configure sshd_config
vi /etc/ssh/sshd_config
Find the following line , use # The symbols are annotated .
# Subsystem sftp /usr/libexec/openssh/sftp-server
# Add the following lines to the last side of the file
Subsystem sftp internal-sftp
# Match users
Match User sftp1
ChrootDirectory /data/sftp/sftp1
ForceCommand internal-sftp
AllowTcpForwarding no # Not necessary
X11Forwarding no # Not necessary
# Set up Chroot The directory permissions ( must ), The user directory, group directory and data root directory should be set to 755 jurisdiction , Not too high , Otherwise, we may report Permission denied It's abnormal
mkdir -p /data/sftp/sftp1
chown root:root /data/sftp/sftp1
chmod 755 /data -R
# establish SFTP The directory that users can write to after logging in upload
mkdir /data/sftp/sftp1/upload
chown sftp1 /data/sftp/sftp1/upload
# to upload And subordinate Document Authorization 777, Otherwise, we may report Permission denied It's abnormal
chmod 777 /data/sftp/sftp1/upload -R
# Restart sshd service :
systemctl restart sshd.service
Finally using flashfxp Enter account sftp1 , password : [email protected] Log in .
2、 Add user groups and users and set up profiles
# Create user group sftp And new users sftp1
groupadd sftp
adduser sftp1
# Add users to user groups
useradd -G sftp -s /sbin/nologin sftp1
# Set the user password
passwd [email protected]
# Disable this user shell Sign in
usermod -s /bin/false sftp1
# Set up sshd_config
vi /etc/ssh/sshd_config
Find the following line , use # The symbols are annotated .
# Subsystem sftp /usr/libexec/openssh/sftp-server
# find Subsystem sftp This business , Modified into :
Subsystem sftp internal-sftp
Match Group sftp
UsePAM yes
# use chroot Assign the user's root directory to %h,%h On behalf of the user home Catalog , So the user It can only be active in the user directory . Also available %u,%u On behalf of user name
ChrootDirectory /data/sftp/%u
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no
# Set up Chroot The directory permissions ( must ), User directory sftp1 And group directory sftp And the data root directory data Must be set to 755 jurisdiction , Not too high , Otherwise, we may report Permission denied It's abnormal
mkdir -p /data/sftp/sftp1
chown root:root /data/sftp/sftp1
chmod 755 /data -R
# establish SFTP The directory that users can write to after logging in upload
mkdir /data/sftp/sftp1/upload
chown sftp1 /data/sftp/sftp1/upload
# to upload And subordinate Document Authorization 777, Otherwise, we may report Permission denied It's abnormal
chmod 777 /data/sftp/sftp1/upload -R
# Restart sshd service :
systemctl restart sshd.service
Finally using flashfxp Enter account sftp1 , password : [email protected] Log in .
3、 Delete the user and re create the user
# If you already have users , Remove
userdel sftp1
rm -rf /home/sftp1
rm -rf /var/spool/mail/sftp1
# newly build sftp Group 、 Specific users sftp1
groupadd sftp
adduser sftp1
useradd -G sftp -s /sbin/nologin sftp1
passwd [email protected]
# modify ssh The configuration file
vi /etc/ssh/sshd_config
Find the following line , use # The symbols are annotated .
#Subsystem sftp /usr/libexec/openssh/sftp-server
Subsystem sftp internal-sftp
UsePAM yes
# use chroot Assign the user's root directory to %h,%h On behalf of the user home Catalog , So the user It can only be active in the user directory . Also available %u,%u On behalf of user name
ChrootDirectory /data/sftp/%u
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no
# Set up Chroot The directory permissions ( must ), The user directory, group directory and data root directory should be set to 755 jurisdiction , Not too high , Otherwise, we may report Permission denied It's abnormal
mkdir -p /data/sftp/sftp1
chown root:root /data/sftp/sftp1
chmod 755 /data -R
# establish SFTP The directory that users can write to after logging in upload
mkdir /data/sftp/sftp1/upload
chown sftp1 /data/sftp/sftp1/upload
# to upload And subordinate Document Authorization 777, Otherwise, we may report Permission denied It's abnormal
chmod 777 /data/sftp/sftp1/upload -R
# restart ssh
service sshd restart
Finally using flashfxp Enter account sftp1 , password : [email protected] Log in .
边栏推荐
- Learning notes - steps of JDBC connection database operation
- CDGA|从事通信行业,那你应该考个数据管理证书
- Dlib+opencv library for fatigue detection
- nacos配置文件发布失败,请检查参数是否正确的解决方案
- Stanford, salesforce|maskvit: masked vision pre training for video prediction
- Learn MySQL from scratch - database and data table operations
- Lumiprobe phosphide hexaethylene phosphide specification
- 【pytorch记录】模型的分布式训练DataParallel、DistributedDataParallel
- 宝,运维100+服务器很头疼怎么办?用行云管家!
- Go语言高级
猜你喜欢
SuperVariMag 超导磁体系统 — SVM 系列
Lake shore optimag superconducting magnet system om series
Solution of intelligent supply chain management platform in aquatic industry: support the digitalization of enterprise supply chain and improve enterprise management efficiency
Dlib+Opencv库实现疲劳检测
生鲜行业B2B电商平台解决方案,提高企业交易流程标准化和透明度
kubernetes命令入门(namespaces,pods)
6月刊 | AntDB数据库参与编写《数据库发展研究报告》 亮相信创产业榜单
Lake Shore—OptiMag 超导磁体系统 — OM 系列
【直播预约】数据库OBCP认证全面升级公开课
Prices of Apple products rose across the board in Japan, with iphone13 up 19%
随机推荐
Netease games, radical going to sea
Golang error handling
Clean up system cache and free memory under Linux
Shell array
混沌工程平台 ChaosBlade-Box 新版重磅发布
[live broadcast appointment] database obcp certification comprehensive upgrade open class
Bao, what if the O & M 100+ server is a headache? Use Xingyun housekeeper!
Stanford, salesforce|maskvit: masked vision pre training for video prediction
制造业SRM管理系统供应商全方位闭环管理,实现采购寻源与流程高效协同
AI training speed breaks Moore's law; Song shuran's team won the RSS 2022 Best Paper Award
Dom4J解析XML、Xpath检索XML
Lake Shore—OptiMag 超导磁体系统 — OM 系列
Altair HyperWorks 2022软件安装包和安装教程
indexof和includes的区别
ACM mm 2022 video understanding challenge video classification track champion autox team technology sharing
Dlib+opencv library for fatigue detection
记一次 .NET 差旅管理后台 CPU 爆高分析
ES6 summary "suggestions collection" of array methods find(), findindex()
线程的并行、并发、生命周期
More information about M91 fast hall measuring instrument