使用 putty 从 windows 到 Linux 的 scp

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

Using putty to scp from windows to Linux

linuxwindowssshputtyscp

提问by Chris Phillips

I'm trying to test some C code that I'm writing. The only issue is that the code needs to be executed on a remote machine. My laptop is pretty old, and there is no driver for my wireless card available for Ubuntu, so booting into Linux to circumvent this problem isn't an option. Here's my question:

我正在尝试测试我正在编写的一些 C 代码。唯一的问题是代码需要在远程机器上执行。我的笔记本电脑很旧,我的无线网卡没有驱动程序可用于 Ubuntu,因此无法启动到 Linux 来规避这个问题。这是我的问题:

I'm using putty to SSH into the remote machine, and I'm writing my code on Notepad++. The location of my file is: C:\Users\Admin\Desktop\WMU\5260\A2.c

我正在使用腻子通过 SSH 连接到远程机器,并且我正在 Notepad++ 上编写我的代码。我的文件的位置是: C:\Users\Admin\Desktop\WMU\5260\A2.c

My problem is that when I use the command scp C:\Users\Admin\Desktop\WMU\5260\A2.c ~I get the error could not resolve hostname C:. Name or service not known".

我的问题是当我使用命令时scp C:\Users\Admin\Desktop\WMU\5260\A2.c ~出现错误could not resolve hostname C:. Name or service not known".

I've also tried scp Users\Admin\Desktop\WMU\5260\A2.c ~which gives me the error Cannot stat 'Users\Admin\Desktop\WMU\5260\A2.c': no such file or directory

我也试过scp Users\Admin\Desktop\WMU\5260\A2.c ~这给了我错误Cannot stat 'Users\Admin\Desktop\WMU\5260\A2.c': no such file or directory

What am I doing incorrectly?

我做错了什么?

采纳答案by nobody

You need to tell scpwhere to send the file. In your command that is not working:

您需要告诉scp将文件发送到何处。在您不起作用的命令中:

scp C:\Users\Admin\Desktop\WMU60\A2.c ~

You have not mentioned a remote server. scpuses :to delimit the host and path, so it thinks you have asked it to download a file at the path \Users\Admin\Desktop\WMU\5260\A2.cfrom the host Cto your local home directory.

您没有提到远程服务器。scp用于:分隔主机和路径,因此它认为您已要求它在\Users\Admin\Desktop\WMU\5260\A2.c从主机C到本地主目录的路径中下载文件。

The correct upload command, based on your comments, should be something like:

根据您的评论,正确的上传命令应该类似于:

C:\> pscp C:\Users\Admin\Desktop\WMU60\A2.c [email protected]:

If you are running the command from your home directory, you can use a relative path:

如果您从主目录运行命令,则可以使用相对路径:

C:\Users\Admin> pscp Desktop\WMU60\A2.c [email protected]:

You can also mention the directory where you want to this folder to be downloaded to at the remote server. i.e by just adding a path to the folder as below:

您还可以提及要将此文件夹下载到远程服务器上的目录。即只需添加文件夹的路径,如下所示:

C:/> pscp C:\Users\Admin\Desktop\WMU60\A2.c [email protected]:/home/path_to_the_folder/

回答by Swaps

You can use PSCPto copy files from Windows to Linux.

您可以使用PSCP将文件从 Windows 复制到 Linux。

  1. Download PSCP from putty.org
  2. Open cmd in the directory with pscp.exe file
  3. Type command pscp source_file user@host:destination_file

  1. 从 putty.org 下载 PSCP
  2. 在有pscp.exe文件的目录下打开cmd
  3. 键入命令 pscp source_file user@host:destination_file

Reference

参考

回答by s4ndhyac

Use scp priv_key.pem source user@host:targetif you need to connect using a private key.

使用scp priv_key.pem source user@host:target,如果你需要使用私钥进行连接。

or if using pscp then use pscp -i priv_key.ppk source user@host:target

或者如果使用 pscp 然后使用 pscp -i priv_key.ppk source user@host:target