Linux scp 将目录复制到另一台具有私钥身份验证的服务器

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

scp copy directory to another server with private key auth

linuxsshcopyfile-transferscp

提问by user2693017

is there something wrong with this scp command ?

这个 scp 命令有问题吗?

scp -C -i ./remoteServerKey.ppk -r /var/www/* [email protected]:/var/www

I use the same .ppk as in putty and enter the same passphrase, but it asks me 3 times and than says connection denied. I thought I used it before and it worked, but it isn′t atm. If it is wrong, how should I do it ?

我使用与 putty 相同的 .ppk 并输入相同的密码,但它询问了我 3 次,然后说连接被拒绝。我以为我以前用过它并且有效,但它不是 atm。如果是错误的,我应该怎么做?

采纳答案by abasterfield

Putty doesn't use openssh key files - there is a utility in putty suite to convert them.

Putty 不使用 openssh 密钥文件 - Putty 套件中有一个实用程序可以转换它们。

edit: it is called puttygen

编辑:它被称为腻子

回答by Borja Tarraso

The command looks quite fine. Could you try to run -v (verbose mode) and then we can figure out what it is wrong on the authentication?

该命令看起来很不错。您能否尝试运行 -v(详细模式),然后我们可以找出身份验证出了什么问题?

Also as mention in the other answer, maybe could be this issue - that you need to convert the keys (answered already here): How to convert SSH keypairs generated using PuttyGen(Windows) into key-pairs used by ssh-agent and KeyChain(Linux)OR http://winscp.net/eng/docs/ui_puttygen(depending what you need)

同样在另一个答案中提到,也许可能是这个问题 - 您需要转换密钥(已在此处回答):How to convert SSH keypairs generated using PuttyGen(Windows) into key-pairs used by ssh-agent and KeyChain( Linux)http://winscp.net/eng/docs/ui_puttygen(取决于您的需要)

回答by Lokesh

Covert .ppk to id_rsa using tool PuttyGen, (http://mydailyfindingsit.blogspot.in/2015/08/create-keys-for-your-linux-machine.html) and

使用工具 PuttyGen 将 .ppk 转换为 id_rsa,(http://mydailyfindingsit.blogspot.in/2015/08/create-keys-for-your-linux-machine.html)和

scp -C -i ./id_rsa -r /var/www/* [email protected]:/var/www

it should work !

它应该工作!

回答by Abhishek Goel

or you can also do ( for pemfile )

或者你也可以做(对于pem文件)

 scp -r -i file.pem [email protected]:/home/backup /home/user/Desktop/