Use SFTP to upload and download CFS file system data
prerequisite
background information
Operation steps
-
Log in to ECS BCC -
Modify the configuration file/etc/ssh/sshd_config -
Comment out the Subsystem line in the sshd_config configuration file, and add a new line Subsystem sftp internal sftp # override default of no subsystems #Subsystem sftp /usr/libexec/openssh/sftp-server Subsystem sftp internal-sftp -
Add the following content at the end of the sshd_config file. Where/usr/sftp is the sftp root directory, please modify it according to the actual situation X11Forwarding no AllowTcpForwarding no ForceCommand internal-sftp ChrootDirectory /usr/sftp
-
-
Set related permissions -
3.1 Execute the following command to add user groups. groupadd sftp -
3.2 Execute the following command to add users and set them as SFTP groups. useradd -g sftp -s /sbin/nologin -M sftp -
3.3 Execute the following command to set the SFTP user password. passwd sftp -
3.4 Create the root directory, owner and group of the SFTP user, and modify the permissions (755). cd /usr mkdir sftp chown root:sftp sftp chmod 755 sftp
-
-
In the SFTP directory, create the CFS mount directory and modify the permissions
cd sftp/ mkdir mnt chown sftp:sftp mnt
-
Execute the following command to mount the CFS file system to /usr/sftp/mnt catalog
mount -t nfs4 -o minorversion=1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport cfs-q2BPKzxxxx.lb-5179xxxx.cfs.bj.baidubce.com:/ /usr/sftp/mnt
-
Execute the following command to restart the sshd service service sshd restart -
Log in to SFTP service, upload and download files