使用SSH复制目录

我怎样才能通过ssh在我的服务器上复制一个目录

cp -r directory_name destination 
  -R, -r, --recursive copy directories recursively 

…也许你想在主机之间交换文件夹。 比你应该使用rsync

 rsync -vaz --rsh="ssh -l username" ~/bk targetHost:~/test 

焦油也将是这个工作的候选人:

 tar cf - . | ssh user@host 'cd /$destination && tar xBf -' 

你可以用rsync或者scp来完成,两者都通过ssh。

 scp -rp directory remotehost:/path/to/directory rsync -azv -e ssh directory/ remotehost:/path/to/directory