Baidu AI Cloud
中国站

百度智能云

Cloud File Storage

Use SFTP to Upload and Download CFS File System Data

This document describes how to use SFTP to upload and download data on the CFS file system.

Precondition

In the area where the CFS file system is located, Baidu Cloud Compute (BCC) instance IS purchased (the following introduction will take the CentOS operating system as an example), please refer to Create BCC Instance.

Background Information

The transmission speed of SFTP depends on the external network bandwidth of the BCC. Please configure the appropriate network bandwidth according to business requirements.

Operation Steps

1.Log in to the Baidu Cloud Compute(BCC) 2.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. Among them, /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

3.Set related privileges

  • 3.1 Execute the following command to add a user group

    groupadd sftp 
  • 3.2 Execute the following command to add users and set them as SFTP group

    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 privileges (755)

     cd /usr 
     mkdir sftp 
     chown root:sftp sftp 
    chmod 755 sftp 

4.In the SFTP directory, create a CFS mount directory and modify the privileges

cd sftp/ 
mkdir mnt 
chown sftp:sftp mnt 

5.Execute the following command to mount the CFS file system to the /usr/sftp/mnt directory

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 

6.Execute the following command to restart the sshd service

service sshd restart 

7.Log in to the SFTP service, upload and download files

The account and password are the user and password configured in Step 3. Here we take the Cyberduck client as an example. You can use a client that supports the SFTP protocol to connect according to the actual situation.

Previous
Cross-region or Cross-account File System Use
Next
Use Rsync to Synchronize from the Old File System to the CFS File System