scp command is not working for copying directory in linux

时间:2016-12-09 13:00:28

标签: linux scp

I am trying to copy selected entire directory from node1 to another node2 from jump instance by using below command but its throwing error. I am able to login to the node1 and from node1 I am also able to login to node2 and vice versa.

Node1 and node2 are identical

scp -r -i abc.pem user1@node1:/abc/abc1/* user2@node2:/abc/abc1/*

Error:

Permission denied (publickey). lost connection

2 个答案:

答案 0 :(得分:1)

-3开关解决了身份验证问题:

scp -3 -r -i abc.pem user1@node1:/abc/abc1/* user2@node2:/abc/abc1/*

这将从您的工作站对两台机器进行身份验证,并且是非常标准的做事方式,与其他黑客不同。

答案 1 :(得分:0)

命令 scp user1@host1:file user2@host2:尝试连接到host1,然后从host1连接到host2。您收到的错误消息表明您没有此连接的权限。

一个简单的解决方法是通过本地主机传输以执行复制:

ssh -i abc.pem user1@node1 tar c -C /abc/abc1 . | ssh -i abc.pem user2@node2 tar x -C /abc/abc1