How Can I Use SFTP to Transfer Files Between a Local Linux Computer and a Linux ECS?
Scenarios
You want to use SFTP to transfer files between a local Linux computer and a Linux ECS. The following uses CentOS as an example.
Procedure
- Log in to the ECS as user root.
- Run the following command to check the OpenSSH version, which is expected to be 4.8p1 or later:
Information similar to the following is displayed:
# OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
- Create a user group and a user (for example, user1).
groupadd sftp
useradd -g sftp -s /sbin/nologin user1
- Set a password for the user.
Figure 1 Setting a password
- Assign permissions to directories.
chmod 755 -R /home/user1
mkdir /home/user1/upload
chown -R user1:sftp /home/user1/upload
chmod -R 755 /home/user1/upload
- Run the following command to edit the sshd_config configuration file:
vim /etc/ssh/sshd_config
Comment out the following information:#Subsystem sftp /usr/libexec/openssh/sftp-server
Add the following information:
Subsystem sftp internal-sftp Match Group sftp ChrootDirectory /home/%u ForceCommand internal-sftp AllowTcpForwarding no X11Forwarding no
Figure 2 sshd_config file with the added information
- Run the following command to restart the ECS:
service sshd restart
Alternatively, run the following command to restart sshd:
systemctl restart sshd
- Run the following command on the local computer to set up the connection:
- Run the sftp command to check the connection.
- Transfer files or folders.
To upload files or folders, run the put -r command.
To download files or folders, run the get -r command.
File Upload/Data Transfer FAQs
- How Do I Upload Files to My ECS?
- How Can I Transfer Files from a Local Windows Computer to a Windows ECS?
- How Can I Use OBS to Transfer Files from a Local Windows Computer to a Windows ECS?
- How Can I Use WinSCP to Transfer Files from a Local Windows Computer to a Linux ECS?
- How Can I Transfer Files from a Local Mac to a Windows ECS?
- How Can I Use SCP to Transfer Files Between a Local Linux Computer and a Linux ECS?
- How Can I Use SFTP to Transfer Files Between a Local Linux Computer and a Linux ECS?
- How Can I Use FTP to Transfer Files from a Local Windows Computer to a Windows or Linux ECS?
- How Can I Use FTP to Transfer Files Between a Local Linux Computer and a Linux ECS?
- How Can I Transfer Data Between a Local Computer and a Windows ECS?
- What Should I Do If the Connection Between the Client and the Server Times Out When I Upload a File Using FTP?
- What Should I Do If Writing Data Failed When I Upload a File Using FTP?
- Why Does Internet Access to an ECS Deployed with FTP Fail?
- Why Am I Seeing an FTP Folder Error When I Open a Folder on an FTP Server?
- Why Do I Fail to Connect to a Linux ECS Using WinSCP?
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbotmore