我想在 CentOs 上配置服务器 SFTP。我已经在 Ubuntu 服务器上进行了测试,它运行良好!
看来用户和服务器的位置很重要。
我在 /
和用户 bob 中创建了一个文件夹 /sftp
:
mkdir /sftp
chmod 777 /sftp
adduser --home /sftp bob
当我将 bob 连接到 sftp 服务器并使用 ls
时,我收到消息“permission denied”:
sftp -P 2222 bob@x.x.x.x
sftp>ls
remote readdir("/") : Permission denied
但是要知道,如果我在 /etc/passwd
中更改用户 bob 的位置,它就会起作用!
chmod 777 /etc
nano /etc/passwd
bob:x:5000:99::/sftp:/bin/bash ---> bob:x:5000:99::/etc:/bin/bash
service proftpd restart
# On client
sftp -P 2222 bob@x.x.x.x
sftp>ls
files ...
所以我无法在 /etc
之外创建我的服务器,为什么?我已经在不同版本的 proftpd 上进行了测试。
因为我注意到在我的 Ubuntu 服务器上工作正常,如果我将 /sftp
放在 /etc
中,put
命令就会出现问题,但如果我将 /sftp
放在根“put”中,效果很好。
我的文件 proftpd.conf 是基本配置:
## basic config ...
SFTPEngine on
Port 2222
SFTPLog /var/log/proftpd/sftp.log
TransferLog /var/log/proftpd/sftp-xferlog
# Host Keys
SFTPHostKey /etc/ssh/ssh_host_rsa_key
SFTPHostKey /etc/ssh/ssh_host_dsa_key
# Auth methods
SFTPAuthMethods password
AuthUserFile /etc/proftpd/sftp.passwd
# SFTP specific configuration
DefaultRoot ~
最佳答案
已找到解决方案! CentOS 的安全服务限制了对某些目录的访问。所以只是禁用。
nano /etc/selinux/config
SELINUX=disabled
#reboot system
关于linux - proftpd sftp CentOS 权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23386335/