How do I move a folder to another directory in SSH?
I used to transfer files between PCs in SSH using the SCP command, but I think it is so complicated that only a single file can be transferred each time. So I wonder how do I move a folder to another directory in SSH? ”
- Question from a user
As a network communication protocol, SSH (Secure Shell) enables two computers to communicate and share data. In this tutorial, we will give you a thorough guide on SSH copy folder from local to remote Windows using the SCP command, which is based on the SSH protocol and enables you to securely transfer files from PC to PC.
SCP offers a wide range of options that regulate every facet of its activity. The following are the most common ones. Be familiar with them before knowing how to transfer folder from local to remote SSH.
- ✲-P -Sets the remote host ssh port.
- ✲-p -Preserves file access and modification times.
- ✲-q -Disables the progress bar and non-error warnings.
- ✲-C -Instructs SCP to compress the data before sending it to the target system.
- ✲-r -Instructs SCP to copy directories recursively.
How to transfer folder from local to remote SSH
Here in this post, we’ll introduce how to transfer folder from local to remote SSH with SCP command. As a supplement, we’ll also introduce how to transfer folder from remote to local SSH. Let’s get started.
Before operations, here are some tips you need to know.
- To perform the SCP command, you have to download an SSH client. PuTTY is a common choice on Windows systems.
- Since it relies on an SSH (Secure Shell) tunnel to transfer data, the SCP command requires authentication with an SSH key, whose function is similar to that of user names and passwords.
- When copying a folder with the same name and location on both systems, take caution because SCP will automatically overwrite the file names.
- To copy a folder, you must at least have read permission on the source computer and write permission on the target system.
Part 1. Copy folder from local to remote with SCP command
Step 1. Run the following command to copy the folder from local to a remote system.
scp -r /path/of/your/local/folder [email protected]:/path/to/remote/server/folder
- ▶path of your local folder: the name of the local folder
- ▶username: the username of the local computer
- ▶hostname: the IP address of the remote device
- ▶path to remote server folder: the target location you want to copy folder to (If no remote directory is supplied, the folder will be copied to the remote user’s home directory.)
Step 2. Enter the user password to start the process.
Part 2. Copy folder from remote to local with SCP command
Step 1. Run the following command:
scp -r [email protected]:/path/of/remote/server/folder /path/to/local/destination/folder
Step 2. Enter the user password to start the process.
Now you can go to the local destination to check your target folder.
AnyViewer: Transfer folder directly between PCs in an easier way
Now you may grasp how to transfer folder from local to remote SSH. You could believe that using SSH to copy a folder from a remote location to a local one takes a lot of time, or that configuring PuTTY to utilize the SCP command is difficult. In this situation, we advise using AnyViewer to easily transfer folders across computers without the need for technical knowledge.
AnyViewer is a free third-party file transfer tool, which is highly appreciated for the following advantages:
- Easy-to-use. It has easy operations to transfer folders without restrictions.
- Fast. It has a fast file transfer speed, for example, it only costs about 20 seconds to transfer a 2 GB zip file when both computers are on LAN.
- Multi-function. In addition to file transfer, AnyViewer also allows you to share screen, manage your computer remotely, communicate via chat box in a remote session, etc.
- Unattended. It offers unattended remote access to PCs and laptops without complicated settings.
Step 1. On the client PC, go to Log in on the left panel and then click Sign up (log in directly if you have already signed up).
Step 2. Fill in the sign-up information.
Step 3. Log in to the same account on other computers, and you can see the assigned devices.
Step 4. Go to the Device interface to select the target device you want to transfer files to, and then click File Transfer.
Step 5. A File Transfer dialog box for transferring files between the PCs is now available. The right of the box presents the client PC, and the host PC is on the left. Select the target folder and click the right arrow to transfer it to the client PC, and vice versa.
You can see the transfer status at the bottom of the box. Right-click to pause or remove the tasks.
- A single file smaller than 100 MB can be transferred using AnyViewer's free account, and you are only permitted to transfer up to 100 files at once. To transfer larger files, upgrade to a Professional or Enterprise plan. The following rights will thereafter be yours:
- Transfer multiple files all at once.
- Speedier file transfer. Transfer speed for a free account is 500 KB/s, but it can reach 10 MB/s for a paid account.
- Assign more devices to the same account to achieve direct file transfer.
- Connect to the host computer in privacy mode so that you can block the remote PC's keyboard and mouse and black its screen.
You may now understand how to transfer folder from local to remote SSH. This technique calls for some IT expertise and it may be difficult for you. You can try AnyViewer in this situation to transfer folders securely between PCs.