当前位置:网站首页>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.serviceFinally 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 .
边栏推荐
- 6月刊 | AntDB数据库参与编写《数据库发展研究报告》 亮相信创产业榜单
- Lake Shore - crx-em-hf low temperature probe station
- Appgallery connect scenario development practice - image storage and sharing
- Is PMP cancelled??
- [pytorch record] distributed training dataparallel and distributeddataparallel of the model
- Bao, what if the O & M 100+ server is a headache? Use Xingyun housekeeper!
- bean的生命周期核心步骤总结
- ES6数组去重的三个简单办法
- How to use the low code platform of the Internet of things for personal settings?
- PMP是被取消了吗??
猜你喜欢

Viewing the whole ecology of Tiktok from a macro perspective

Solution of intelligent supply chain management platform in aquatic industry: support the digitalization of enterprise supply chain and improve enterprise management efficiency

Love business in Little Red Book

Stanford, salesforce|maskvit: masked vision pre training for video prediction

Specification of lumiprobe reactive dye indocyanine green

制造业SRM管理系统供应商全方位闭环管理,实现采购寻源与流程高效协同

CDGA|从事通信行业,那你应该考个数据管理证书

linux下清理系统缓存并释放内存

论文阅读【Learning to Discretely Compose Reasoning Module Networks for Video Captioning】

线程的并行、并发、生命周期
随机推荐
Manufacturing SRM management system supplier all-round closed-loop management, to achieve procurement sourcing and process efficient collaboration
[quick application] there are many words in the text component. How to solve the problem that the div style next to it will be stretched
【AGC】如何解决事件分析数据本地和AGC面板中显示不一致的问题?
Solidity - 合约结构 - 错误(error)- ^0.8.4版本新增
Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
Shell array
Create your own NFT collections and publish a Web3 application to show them (Introduction)
Three ways for redis to realize current limiting
Dlib+opencv library for fatigue detection
Lean thinking: source, pillar, landing. I understand it after reading this article
Netease games, radical going to sea
Golang error handling
2. Create your own NFT collections and publish a Web3 application to show them start and run your local environment
Solidity - 算术运算的截断模式(unchecked)与检查模式(checked)- 0.8.0新特性
ES6数组去重的三个简单办法
组队学习! 14天鸿蒙设备开发“学练考”实战营限时免费加入!
Lake Shore 连续流动低温恒温器传输线
Lake Shore M91快速霍尔测量仪
Cdga | if you are engaged in the communication industry, you should get a data management certificate