Mac向Linux远程传输文件夹与文件

  1. 先设置ssh无密码访问
zhangbodeMacBook-Pro:~ zhangbo$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/zhangbo/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/zhangbo/.ssh/id_rsa. 一个私有密钥
Your public key has been saved in /Users/zhangbo/.ssh/id_rsa.pub. 一个公共密钥
 scp id_rsa.pub [email protected]:~/.ssh/authorized_keys 将公共密钥拷贝到目标机器上
chmod 700 ~/.ssh 在目标机器上设置权限
chmod 600 ~/.ssh/authorized_keys   在目标机器上设置权限
  1. 通过scp命令远程从mac向linux拷贝文件或者文件夹(如果不了解scp命令可以在终端中输入 man scp 查看)
// 从{本地当前文件夹中把ideaIU-2016.3.5.tar.gz传输到[email protected]:~/Downloads/} 的目录下
scp ideaIU-2016.3.5.tar.gz [email protected]:~/Downloads/
 // {本地当前文件夹中把文件夹projectData传输到[email protected]:~/Downloads/} 的目录下
 scp -r  projectData/ [email protected]:~/Downloads/
Mac向Linux远程传输文件夹与文件_第1张图片
执行后的效果

你可能感兴趣的:(Mac向Linux远程传输文件夹与文件)