当前位置:网站首页>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 .
边栏推荐
- 精益思想:来源,支柱,落地。看了这篇文章就懂了
- Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?
- Learn MySQL from scratch - database and data table operations
- Solidity - 合约结构 - 错误(error)- ^0.8.4版本新增
- Lake Shore continuous flow cryostat transmission line
- Today, with the popularity of micro services, how does service mesh exist?
- ECS summer money saving secret, this time @ old users come and take it away
- 助力数字经济发展,夯实数字人才底座—数字人才大赛在昆成功举办
- 机械设备行业数字化供应链集采平台解决方案:优化资源配置,实现降本增效
- 11. Users, groups, and permissions (1)
猜你喜欢

11. Users, groups, and permissions (1)

Lake Shore - crx-em-hf low temperature probe station

June issue | antdb database participated in the preparation of the "Database Development Research Report" and appeared on the list of information technology and entrepreneurship industries

XML语法、约束

生鲜行业B2B电商平台解决方案,提高企业交易流程标准化和透明度

Supervarimag superconducting magnet system SVM series

MySQL常用图形管理工具 | 黑马程序员

Dom4J解析XML、Xpath检索XML

Lake Shore—CRX-EM-HF 型低温探针台

C-end dream is difficult to achieve. What does iFLYTEK rely on to support the goal of 1billion users?
随机推荐
Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse
太爱速M源码搭建,巅峰小店APP溢价寄卖源码分享
How to realize the applet in its own app to realize continuous live broadcast
学习笔记【gumbel softmax】
Yyds dry inventory ravendb start client API (III)
The market value evaporated by 74billion yuan, and the big man turned and entered the prefabricated vegetables
微服务大行其道的今天,Service Mesh是怎样一种存在?
Lake Shore M91快速霍尔测量仪
Mipi interface, DVP interface and CSI interface of camera [easy to understand]
Huawei game failed to initialize init with error code 907135000
线程的并行、并发、生命周期
CDGA|从事通信行业,那你应该考个数据管理证书
The best landing practice of cave state in an Internet ⽹⾦ financial technology enterprise
Lake shore M91 fast hall measuring instrument
学习笔记-JDBC连接数据库操作的步骤
组队学习! 14天鸿蒙设备开发“学练考”实战营限时免费加入!
Lumiprobe 活性染料丨吲哚菁绿说明书
MySQL常用图形管理工具 | 黑马程序员
Create your own NFT collections and publish a Web3 application to show them (Introduction)
精耕渠道共谋发展 福昕携手伟仕佳杰开展新产品培训大会