I am executing a BASH shell script (downloadScript.sh) on a remote server in the below way. Since the script takes more time to execute, the remote shell is getting timed out in between.

ssh -i aws.pem username@remoteserver "./downloadScript.sh"

Please let me know how can make sure that the remote shell alive till the script execution.

Error message I am receiving:

packet_write_wait: Connection to <remoteserver> port 22: Broken pipe

Note: I don't want to modify any configuration on remote server.

How can I add ServerAliveInterval and ServerAliveCountMax to the ssh -i aws.pem username@remoteserver "./downloadScript.sh" command..!?


1 Answer 1


As per your comment to Vlastimil, You can use -o parameter in your ssh command. Example could be

ssh -o ServerAliveInterval=60 -i aws.pem username@remoteserver "./downloadScript.sh"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .