Uploading and Downloading Files to and from a Server using SCP
Commands
scp
is probably an abbreviation for server copy. It’s a command used for uploading and downloading when using an ssh server.
Pay attention to the spaces and the positions of @ and :. Let’s call the server account serverACC, the server address serverADD, the directory on the server where files will be uploaded or downloaded serverDIR, the file or directory I want to transfer Object, and the directory where I want to download files localDIR.
- Upload
scp Object serverACC@serverADD:serverDIR
- Directory Upload
scp -r Object serverACC@serverADD:serverDIR
- Download
scp serverACC@serverADD:"Object" localDIR
- Directory Download
scp -r serverACC@serverADD:Object localDIR
For example, the following command transfers a file named image.png from my computer’s C drive to the directory D:\result on the server with ip address 121.150.155.230 and the account name fresh I can use on the server:
scp C:\image.png fresh@121.150.155.230:D:\result