将文件从远程Ubuntu复制到本地Mac

我四处搜索,似乎无法找到这个……我正在尝试将私钥复制到我的本地机器上,这是一台Mac机。

当我在我的Mac上启动终端时,我得到了Jamies-iMac:~ jamie$

所以在我进入我的Ubuntu服务器后,我试过了

 scp /path/to/myfile.txt jamie@Jamies-iMac:/path/to/myfile.txt 

这给了我:

 ssh: Could not resolve hostname Jamies-iMac: Name or service not known lost connection 

代替jamie@Jamies-iMac:/path/to/myfile.txt我尝试了其他一些变化,但似乎没有任何效果。 谢谢你的帮助。

@ovc没错,但是语法错误,我的编辑因某种原因被拒绝了。 你需要在ubuntu端的用户和文件路径之间有一个冒号,而在mac端你需要在文件路径中有/Users/username/部分。 像这样:

 scp username@192.168.1.111:/path/to/myfile.txt /Users/Jamie/local/path/to/myfile.txt 

你这样做是错误的。 只需在Mac上使用scp命令,如下所示: scp username@192.168.1.111/path/to/myfile.txt /local/path/to/myfile.txt 。 您也可以使用FileZilla ,它是一个图形客户端。 使用类似sftp://192.168.1.111的URL连接到您的Ubuntu,当然您需要使用有效的IP地址。

上面的优秀答案。 此外,如果需要使用证书进行身份validation,可以使用-i标志。

 scp -i /path/to/cert username@192.168.1.111:/path/to/myfile.txt /Users/Jamie/local/path/to/myfile.txt