SSH connect two droplets and can I access files in python script?

Posted April 20, 2017 3.2k views

I posted my question about SSH networking here:

I will repeat it:
I have access from my pc to both of my droplets with ssh and putty. At my pc I have the public and the private (.ppk) ssh keys. This works fine.

Now I want both droplets to rsync in private network. I assueme I can still use the public and private keys I also use on pc in putty.
But where do I put public and private key, so the first droplet knows that he can use this ssh keys to connect to droplet2 ?

2) After transferring files with SSH is possible, if want a python 3 script that is running at one of them, to be able to read txt files from the other droplet.
Does anyone has a clue how to do that?

1 comment

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer


The purpose of rysnc would be to ensure that the specified files and directories on Droplet A are in sync with Droplet B and vice versa. If that’s the case, you should be able to simply read the file on the server that you’re running the Python script on without having to go over the network to do it.

As a very basic example, if we have a file called demo.txt and it exists on Droplet A, and you’re using rsync to duplicate that file over to Droplet B, then you should be able to read that file on either using a Python script without having to go over the network.

Any changes you make on either Droplet A or Droplet B could then be synced using rysnc.

If you need to connect over SSH from your Python script, I’d take a look at the following. There are a few demo scripts that you can use to get things setup.

  • Thank you very much for the reply :)

    Since I have access to both droplets, I could also manually update all files at both droplets.
    But I would like to automatie this, since on both droplets a python script is running, that is printing some output in a txt file.
    And the other droplet should be aware of the latest output, so the python script should be able to read files from the other droplet.

    I guess the best way would be to automatce rsync without python? Is this possible?
    Eg. every 30 seconds a txt file I choose is rsnyced ? That would solve the problem I think.

    But I also would need an answer to question number 1.

    I think I can follow this guide:

    I’m not sure if two ssh are possible? A password secured ssh to the puplic connection and a passwordless ssh from private to private?

    I would like to request some feedback, if this guide is the solution, or not :)