Scp Command Syntax for Copying a Folder from Local MAChine to a Remote Server

How do I copy a folder from remote to local using scp?

scp -r user@your.server.example.com:/path/to/foo /home/user/Desktop/

By not including the trailing '/' at the end of foo, you will copy the directory itself (including contents), rather than only the contents of the directory.

From man scp (See online manual)

-r Recursively copy entire directories

Copying a local file from Windows to a remote server using scp

If your drive letter is C, you should be able to use

scp -r \desktop\myfolder\deployments\ user@host:/path/to/whereyouwant/thefile

without drive letter and backslashes instead of forward slashes.

You are using putty, so you can use pscp. It is better adapted to Windows.

Scp command syntax for copying a folder from local machine to a remote server

In stall PuTTY in our system and set the environment variable PATH Pointing to putty path.
open the command prompt and move to putty folder. Using PSCP command

Please check this

Copying files from server to local computer using SSH

It depends on what your local OS is.

If your local OS is Unix-like, then try:

scp username@remoteHost:/remote/dir/file.txt /local/dir/

If your local OS is Windows ,then you should use pscp.exe utility.
For example, below command will download file.txt from remote to D: disk of local machine.

pscp.exe username@remoteHost:/remote/dir/file.txt d:\

It seems your Local OS is Unix, so try the former one.


For those who don't know what pscp.exe is and don't know where it is, you can always go to putty official website to download it. And then open a CMD prompt, go to the pscp.exe directory where you put it. Then execute the command as provided above

EDIT

if you are using Windows OS above Windows 10, then you can use scp directly from its terminal, just like how Unix-like OS does.
Thanks to @gijswijs @jaunt @icanfathom

Is it possible to copy files from local windows directory to remote linux directory?

Yes it can be possible, but you need additional software for that. Both Putty or Git bash will work. Since I use git as VCS, I also use it to send files from my Window 7 laptop to remote AWS Linux machine.

Example login:

ssh -i key.pem user-name@public-dns **or** ip-address

To send a file from Window to remote (like AWS ec2):

scp -i key.pem file.txt user-name@public-dns:~/

To send a directory from Window to remote:

scp -i key.pem -r directory_name user-name@public-dns:~/

To receive a file from remote to Window:

scp -i key.pem user-name@public-dns:/file-address/file.txt any_name.txt

To recieve a directory from remote to Window:

scp -i key.pem -r user-name@public-dns:/directory-address/directory any_name

Copy .sh file from my local computer to the remote server

Imagine hello.txt is the file you want to move. Directory you are standing on contains this file.

Run scp hello.txt root@YOUR_SERVER:/root.

This will copy hello.txt to your root's home directory. Run cd ~ on your server and you will see your file.

In this example I used root account, but you can also use another account too

How to move file from Windows local machine to Linux remote server

Assuming D is the drive you installed windows on the syntax would be

scp D:\Users\YOURUSERNAME\Desktop\test.txt USERNAME@remoteserver:~/Desktop/test.txt

The backslash for your windows path is okay, use forward slashes for the ssh remote server path

If you have a private key with which you can connect to the remote server you can provide it with the -i flag

scp -i ~/.ssh/privatekey.pem D:\Users\YOURUSERNAME\Desktop\test.txt USERNAME@remoteserver:~/Desktop/test.txt

The standard port for an ssh server would be 22 if it is another port than provide that with the -p flag e.g. -p 2222

Double check if the remote host is reachable e.g. use nmap or zenmap and port is open. Good luck.

PS: There is also a Putty Secure Copy program available through the pscp utility. You can launch it separately from putty in the command prompt

the syntax for that would be a forward slash for your local windows folder too e.g.

pscp c:/music.mp3 ubuntu@10.0.0.3:/home/ubuntu/Music

How to copy a directory from local machine to remote machine

Easiest way is scp

scp -r /path/to/local/storage user@remote.host:/path/to/copy

rsync is best for when you want to update versions where it has been previously copied.

If that doesn't work, rerun with -v and see what the error is.



Related Topics



Leave a reply



Submit