- 先设置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 7m-test@192.168.2.51:~/.ssh/authorized_keys 将公共密钥拷贝到目标机器上
chmod 700 ~/.ssh 在目标机器上设置权限
chmod 600 ~/.ssh/authorized_keys 在目标机器上设置权限
- 通过scp命令远程从mac向linux拷贝文件或者文件夹(如果不了解scp命令可以在终端中输入 man scp 查看)
// 从{本地当前文件夹中把ideaIU-2016.3.5.tar.gz传输到debian@192.168.2.54:~/Downloads/} 的目录下
scp ideaIU-2016.3.5.tar.gz debian@192.168.2.54:~/Downloads/
// {本地当前文件夹中把文件夹projectData传输到debian@192.168.2.54:~/Downloads/} 的目录下
scp -r projectData/ debian@192.168.2.54:~/Downloads/