Combing the process of adding sftp users to linux
Sometimes, for special needs, the server needs to activate sftp to transfer files to the peer server instead of ftp. Write this as follows:
Operating system linux
1. Add new users
Useradd-g sftponly-s "/ bin/false"-d "/ ftp/usftpuser/" usftpuser
2 、 / etc/ssh/sshd_config
Modify
Subsystem sftp internal-sftp
UsePAM yes
New matching users
Match User usftpuser
ChrootDirectory / ftp/usftpuser
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
Note: the / ftp/usftpuser/,usftpuser directory here must be a root user with 755 permissions, otherwise it cannot be used.
Service sshd restart
Then you can try to log in:
[root@cpsvpn ~] # sftp usftpuser@193.168.4.30
Connecting to 193.168.4.30...
Usftpuser@193.168.4.30's password:
Sftp >
Sftp >
Sftp > ls
Sftp >
Sftp > pwd
Remote working directory: /
Note: if the user usftpuser needs to use the current directory, there must be an administrative root to establish a directory with permissions, otherwise it cannot be used.