如何使用SSH将文件从计算机A传输到本地计算机


10

我正在尝试使用ssh从我的学校Linux帐户中获取一些文件。我已经使用以下连接进行工作:

scp <school_server>: ~/folder I want ~/where I want to go

但是,当它转到传输文件夹时,它会给我消息:

not a regular file

该文件包含.java文件,并且我需要整个文件夹。

Answers:


20

要使用scp递归复制整个目录,您需要添加-r开关

scp -r remotehost:/path/to/remote/dir/ /path/to/local/dir/


1
完美工作,感谢您的快速反应
zombiedad

1

我有需要PEM连接的目的地,并且它也有不同的SSH端口。这对我来说就像魅力一样工作:

例如,将文件夹(和子文件夹)从复制sourceservertargetserver,在sourceserver

$ rsync -azu -e 'ssh -i ./pem_for_target_server.pem -p <port_number_for_target_server>' /folder/path/on/source username_on_target@target.server.name:/path/on/target/where/you/want/to/copy/folder/on/source/

(在你的情况下permissions are too open为PEM文件,运行这个命令: chmod 400 ./pem_for_target_server.pem

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.