Question

ssh fails 60 percent of the time Oo

I am creating a droplet like this : new_droplet=$(curl -X POST “https://api.digitalocean.com/v2/droplets
-d’{“name”:“laminarghost”,“region”:“nyc3”,“size”:“s-1vcpu-2gb”,“image”:“ubuntu-18-04-x64”,“ssh_keys”:[‘$SSH_ID’],“user_data”:null}’
-H “Authorization: Bearer $DO_TOKEN”
-H “Content-Type: application/json”)

after extracting some item from the JSON I am using the following to move a folder and substructure to the droplet:

tar -vczf - * | ssh -o StrictHostKeyChecking=accept-new root@${new_droplet_ip} tar -xzf - -C /opt/

it starts listing files and then stops. 30 percent of the time it announces that the key has been added to known hosts. and proceeds through the rest of the script

the rest of the time it returns ssh: connect to host IP address here port 22: Connection refused tar: -: Wrote only 4096 of 10240 bytes tar: Child returned status 141 tar: Error is not recoverable: exiting now

the ssh takes (15 seconds? ish )to respond, I suspect sometimes it’s longer and times out?

comments and suggestions appreciated


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello, @jefftully

Are you experiencing the same ssh-timeouts when you’re connected with an ssh-client like Putty or using your terminal?

I will recommend you to check our existing tutorial on how to troubleshoot the connection refused errors in ssh:

https://www.digitalocean.com/docs/droplets/resources/troubleshooting-ssh/connectivity/#connection-refused

Hope that this helps! Regards, Alex