1. 添加用户
useradd -s /sbin/nologin test
echo test | passwd --stdin test
2. 修改/etc/ssh/sshd_config
Subsystem sftp internal-sftp
Match User netexr
ChrootDirectory /home/test
ForceCommand internal-sftp
3. 修改目录权限
chown root /home/test
chmod 750 /home/test
如果不做上面两步,那么连接时会报错:
Write failed: Broken pipe
Couldn't read packet: Connection reset by peer
4. 为test用户建能够写入的文件夹
mkdir /home/test/data
chown test.test /home/test/data