惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
Security Latest
Security Latest
P
Privacy International News Feed
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AI
AI
Cisco Talos Blog
Cisco Talos Blog
K
Kaspersky official blog
S
Secure Thoughts
PCI Perspectives
PCI Perspectives
Simon Willison's Weblog
Simon Willison's Weblog
D
DataBreaches.Net
GbyAI
GbyAI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
罗磊的独立博客
V
Visual Studio Blog
aimingoo的专栏
aimingoo的专栏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
V
V2EX
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tenable Blog
T
Threat Research - Cisco Blogs
T
Troy Hunt's Blog
V2EX - 技术
V2EX - 技术
S
Security @ Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
L
Lohrmann on Cybersecurity
F
Full Disclosure
H
Help Net Security
博客园 - Franky
Stack Overflow Blog
Stack Overflow Blog
N
Netflix TechBlog - Medium
Engineering at Meta
Engineering at Meta
A
Arctic Wolf
O
OpenAI News
S
Securelist

Feel.name

Centos7安装sngrep – Feel.name DNS大全 – Feel.name Linux下转换文件编码 – Feel.name Linux服务器密钥登陆方法 – Feel.name 升级到最新OpenSSH_9.3p1, OpenSSL 3.1.1 – Feel.name linux清理缓存(cache) – Feel.name 通过yum来下载RPM包的方法 – Feel.name 年末守望新年期盼 – Feel.name message 日志里面的“Created slice User Slice of root.”日志去除方法 – Feel.name
centos 7上创建sftp服务 – Feel.name
Feel · 2023-06-20 · via Feel.name

Skip to content

环境:centos7

注意:服务器 OpenSSH-Server 版本最低4.8,用 ssh –V 来查看openssh的版本,如果低于4.8,需要自行升级安装。

[root@localhost home]# ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017

sftp优点:sftp比ftp更可取,加密传输,设置也简单。ftp过于繁琐,且是不安全的协议

开启用户SFTP服务

创建sftp组
groupadd sftp
创建测试账户
sudo useradd -g sftp -s /sbin/nologin -M testuser
参数说明:

-g              # 加入用户组
-s              # 指定用户登入后所使用的shell
/sbin/nologin   # 用户不允许登录
-M              # 不要自动建立用户的登入目录

设置用户密码:

passwd testuser
Changing password for user testuser.
New password:

创建目录

mkdir /opt/sftp
cd /opt/sftp
mkdir testuser

设置sftp组根目录权限

chown root:sftp /opt/sftp
chmod 755 /opt/sftp

文件夹所有者必须是root,用户组可以不是root。

设置具体的用户根目录权限:

chown www:sftp -R /opt/sftp/testuser
chmod 775 -R /opt/sftp/testuser

修改测试账户HOME路径:usermod -d /opt/sftp/testuser testuser

配置sshd_config :

vim /etc/ssh/sshd_config
注释掉:Subsystem sftp /usr/libexec/openssh/sftp-server
添加如下几行:

Subsystem  sftp  internal-sftp # 开启sftp
Match Group sftp  # 限制的用户组
ChrootDirectory /opt/sftp/%u  # 根目录
ForceCommand internal-sftp  
AllowTcpForwarding no  
X11Forwarding no  

检测配置:shd -t
重启sshd服务:service sshd restart
测试连接:密码登录:sftp -P 22 testuser@127.0.0.1,密钥登录:sftp -P 22 -i ~/.ssh/id_rsa testuser@127.0.0.1

done!