简体   繁体   中英

scp command - transfer folder over ssh

I have a Arduino Yun and want setup the server for Yun.

So what I want is to copy a folder that contain a py file and a index.html to my Yun

I used mac terminal to do this operation

the command looks like this

scp -r /Users/gudi/Desktop/LobsterHeartRate root@192.168.240.1:/mnt/sda1

and then terminal asked for the password

after I typed, it shows

scp: /mnt/sda1/LobsterHeartRate: Not a directory

I didn't type /mnt/sda1/LobsterHeartRate why it shows this error

As @Jens Höpken notes, your post is a bit sparse. But trying to read between the lines of your post I suspect that LobsterHeartRate is a DIRECTORY on your local system but a FILE named LobsterHeartRate in your target system. This might be happening right at the top of the directory tree, or perhaps you have directories/files of the same name further down the tree. scp -rv might help resolve any confusions here.

scp -r resolves symbolic links. scp -r解析符号链接。 If you want to preserve symlinks you need to do something else. For historic reasons I use the following, though with a front-end opens up interesting possibilities for fine-grained file selections. 前端的为细粒度文件选择提供了有趣的可能性。

( cd /Users/gudi/Desktop && tar -cf - LobsterHeartRate ) |
      ssh root@192.168.240.1 'cd /mnt/sda1 && tar -xf -'

For a safe "dry run" you could change the -xf to a -tf. The && chains are required to prevent bad things from happening if any prior command fails.

Disclaimer: any debugging is left as an exercise for the student.

Your code

scp -r /Users/gudi/Desktop/LobsterHeartRate root@192.168.240.1:/mnt/sda1

requires that the remote directory /mnt/sda1 exists. This looks like it is not true in your case. Check it using ssh root@192.168.240.1 ls /mnt/sda1 .

scp is simple tool and it does not allow you to rename directories on the fly and the target directory must exists. You might try

scp -r /Users/gudi/Desktop/LobsterHeartRate root@192.168.240.1:/mnt/
ssh root@192.168.240.1 mv /mnt/LobsterHeartRate /mnt/sda1

or so, if it will suit your needs. But copying more files, rsync is usually more suitable. Check its manual page and give it a try next time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM