从 Linux 到 Windows 的 scp

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10235778/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 05:54:16  来源:igfitidea点击:

scp from Linux to Windows

linuxwindowspathfile-transferscp

提问by user1344963

I am running a putty client on a Windows machine to connect successfully to a Linux box. Now I want to be able to copy a file from the Linux machine under the path /home/ubuntu/myfileto C:/Users/Anshul/Desktopon my local computer. The user at the Windows machine is anshul. I am giving the following command on putty but it is not working:

我在 Windows 机器上运行腻子客户端以成功连接到 Linux 机器。现在我希望能够从 Linux 机器上的路径下复制文件/home/ubuntu/myfileC:/Users/Anshul/Desktop我的本地计算机上。Windows 机器上的用户是anshul. 我在腻子上给出以下命令,但它不起作用:

scp /home/ubuntu/myfile ip_address_of_windows_machine:C:/Users/Anshul/Desktop 

I think the path for the Windows machine is wrong. Please help as I have banged my head on a large number of forums but none seem to give correct path for Windows server. Don't suggest alternate options like WinScp

我认为 Windows 机器的路径是错误的。请帮忙,因为我已经在大量论坛上敲了敲脑袋,但似乎没有一个为 Windows 服务器提供正确的路径。不要建议替代选项,例如WinScp

回答by theglauber

Windows doesn't support SSH/SCP/SFTPnatively. Are you running an SSH server application on that Windows server? If so, one of the configuration options is probably where the root is, and you would specify paths relative to that root. In any case, check the documentation for the SSH server application you are running in Windows.

Windows 本身不支持SSH/SCP/SFTP。您是否在该 Windows 服务器上运行 SSH 服务器应用程序?如果是这样,配置选项之一可能是根所在的位置,您将指定相对于该根的路径。无论如何,请查看您在 Windows 中运行的 SSH 服务器应用程序的文档。

Alternatively, use smbclientto push the file to a Windows share.

或者,用于smbclient将文件推送到 Windows 共享。

回答by user1645422

If you want to copy paste files from Unix to Windows and Windows to Unix just use filezilla with port 22.

如果您想将粘贴文件从 Unix 复制到 Windows 和从 Windows 复制到 Unix,只需使用带有端口 22 的 filezilla。

回答by Corey Burnett

Try this:

尝试这个:

scp /home/ubuntu/myfile C:\users\Anshul\Desktop

回答by Chris Alexander sebastian

Try this, it really works.

试试这个,它真的有效。

$ scp username@from_host_ip:/home/ubuntu/myfile /cygdrive/c/Users/Anshul/Desktop

And for copying all files

并用于复制所有文件

$ scp -r username@from_host_ip:/home/ubuntu/ *. * /cygdrive/c/Users/Anshul/Desktop

回答by Atif Raza

You could use something like the following

您可以使用以下内容

scp -r username_Linuxmachine@LinuxMachineAddress:Path/To/File Path/To/Local/System/Directory

This will copy the Fileto the specified local directory on the system you are currently working on.

这会将 复制File到您当前正在使用的系统上的指定本地目录。

The -rflag tells scpto recursively copy if the remote path is indeed a directory.

-r标志告诉scp递归复制远程路径是否确实是目录。

回答by Ramarajan Jothi

Here is the solution to copy files from Linux to Windows using SCP without password by ssh:

以下是通过 ssh 使用 SCP 无需密码将文件从 Linux 复制到 Windows 的解决方案:

  1. Install sshpass in Linux machine to skip password prompt

  2. Script

    sshpass -p 'xxxxxxx' scp /home/user1/*.* [email protected]:/d/test/

  1. 在Linux机器上安装sshpass跳过密码提示

  2. 脚本

    sshpass -p 'xxxxxxx' scp /home/user1/*.* [email protected]:/d/test/

Details:

细节:

sshpass -p 'password' scp /source_path/*.* windowsusername@windowsMachine_ip:/destination_drive/subfolder/

回答by Hesham Eraqi

Download pscpfrom Putty download page, then use it from Windows Command Line CMDas follows:

下载pscp腻子下载页面,然后用它从Windows命令行CMD如下:

pscp username_linux_machine@ip_of_linux_machine:/home/ubuntu/myfile.ext C:\Users\Name\Downloads

Copying starts once you enter the password for the Linux machine.

输入 Linux 机器的密码后,复制开始。

回答by Acmag

I know this is old but I was struggling with the same. I haven't found a way to change directories, but if you just want to work with the C drive, scp defaults to C. To scp from Ubuntu to Windows, I ended up having to use (notice the double back-slashes):

我知道这是旧的,但我也在努力解决这个问题。我还没有找到更改目录的方法,但是如果您只想使用 C 驱动器,scp 默认为 C。从 Ubuntu 到 Windows 的 scp,我最终不得不使用(注意双反斜杠):

scp /local/file/path [email protected]:Users\\Anshul\\Desktop

scp /local/file/path [email protected]:Users\\Anshul\\Desktop

Hope this helps someone.

希望这可以帮助某人。

回答by Krzysztof Walczewski

For all, who has installed GiT completly with "Git Bash": You can just write:

对于所有已经使用“Git Bash”完全安装 GiT 的人:您可以这样写:

scp login@ip_addres:/location/to/folders/file.tar .

(with space and DOT at the end to copy to current location). Than just add certificate (y), write password and that's all.

(末尾有空格和 DOT 以复制到当前位置)。不仅仅是添加证书(y),写密码,仅此而已。

回答by emoblazz

This one worked for me.

这个对我有用。

scp /home/ubuntu/myfile username@IP_of_windows_machine:/C:/Users/Anshul/Desktop