使用SSH ubuntu复制文件夹(不是一个文件)?

我正在尝试使用命令行ssh连接将文件夹复制到远程Ubuntu服务器,我知道使用scp传输文件是可行的,但我在一个文件夹中有很多文件,我试图复制到该远程服务器,这是怎么做的? 任何人? 谢谢。

您可以使用带有递归选项( -r )的安全副本(scp):

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

或者,我建议使用rsync,因为如果连接中断,您可以恢复传输,并且它只智能地传输文件之间的差异:

 rsync -avz -e 'ssh' /path/to/local/dir user@remotehost:/path/to/remote/dir 

请注意,在这两种情况下都应该注意尾部斜杠:move /path/to/local/dir to remotehost:/path/to/remote/dir/ results in /path/to/remote/dir/dir