I want to copy content from file on one linux server to file on another linux server with ssh. I am on third machine and I am using one same public key on both linux servers to connect without password.

I know that is something like this:

ssh -A user1@server1 "cat fajl1..."

Use the ssh in a pipe. I will assume you have machines server1, server2 and server3. If you are on server 2, it would look like this:

ssh -A user1@server1 "cat server1file" | ssh user1@server3 "cat >> server3file"

The first ssh command starts a pipeline over the network that the second ssh command picks up and appends to the destination file on its file system.

  • Please write whole command, I dont get where to put "".
    – dukasvili
    Feb 25 '17 at 23:34
  • My example was too simple and did not address your 3 machine problem. I have adjusted the answer.
    – Greg Tarsa
    Feb 25 '17 at 23:53
  • Works! That is right command, I put pipe under " " each time and that messed up everything.Thanks!
    – dukasvili
    Feb 26 '17 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.