'For GCP how to scp file from one node to another node?

On GCP I have a nodepool for our kubernetes cluster and I can ssh to any of the node in the nodepool. However when I tried the scp command on one of the mode to try to copy a file from current node to another node. It says:

Permission denied (publickey).
Lost connection.

This an issue of ssh too. I cannot ssh to another node from the current node.

How to resolve this issue?



Solution 1:[1]

If you can ssh to both the GCP nodes here is the step for you to be able to scp from node A to node B.

  1. local> SSH to node A
  2. nodeA> ssh-keygen -b 4096
  3. nodeA> cat ~/.ssh/id_rsa.pub (then copy the public key content)
  4. local> SSH to node B
  5. nodeB> vi ~/.ssh/authorized_keys (add the copied public key from nodeA as a newline)

Now you can scp from nodeA to nodeB.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peiti Li