macos 将文件从服务器复制到本地硬盘
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10600345/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Copy a file from server to local hard disk
提问by Khalizar
I'm trying to copy a database dump sql file from my server to my hdd using mac OSX Terminal (open ssh client). I know the command should be something like:
我正在尝试使用 mac OSX 终端(打开 ssh 客户端)将数据库转储 sql 文件从我的服务器复制到我的硬盘。我知道命令应该是这样的:
scp [[user]@host]:mydump.sql mydump_local.sql
But I found out that it did copy
that file on the same server instead of my hdd (i.e. using ls *
, I found both files mydump.sql and mydump_local.sql)
但我发现它copy
在同一台服务器上而不是我的硬盘上执行该文件(即使用ls *
,我发现两个文件 mydump.sql 和 mydump_local.sql)
What am I doing wrong?
我究竟做错了什么?
回答by Hoff
first, don't ssh into the remote server. then, I find this to be a very good resource for scp syntax: Example syntax for Secure Copy (scp)
首先,不要通过 ssh 进入远程服务器。然后,我发现这是一个非常好的 scp 语法资源:Secure Copy (scp) 的示例语法
the one your looking for is this: to copy the file "foobar.txt" from a remote host to the local host
您正在寻找的是:将文件“foobar.txt”从远程主机复制到本地主机
$ scp [email protected]:foobar.txt /some/local/directory
if you're still having issues, please post the exact command you're using
如果您仍然遇到问题,请发布您正在使用的确切命令
回答by Larusso
try to use ./mydump_local as the destination when you want it to be placed in the current directory.
当您希望将它放在当前目录中时,尝试使用 ./mydump_local 作为目标。
回答by Christian Kuetbach
If you firt make a ssh connect to the remote host, you'll get a remote shell. If you are coping your file in that remote-shell, you make a scp onto the remote server.
如果您首先通过 ssh 连接到远程主机,您将获得一个远程 shell。如果您在该远程外壳中处理您的文件,则在远程服务器上创建一个 scp。
Don't make a ssh to the remote host, just use scp.
不要对远程主机进行 ssh,只需使用 scp。