how to stop ssh script when golang ssh session is disconnect with remote server

Viewed 125

When I using golang ssh into one server, found my ssh session between golang program and remote server disconnect with error (wait: remote command exited without exit status or exit signal).

So I done a test, after golang program build a connection with remote ubuntu server, I login that server, and using

kill -9 <ssh-session pid>

to kill that ssh session, and the golang program return the same error

wait: remote command exited without exit status or exit signal

However, I found the ssh script that golang program had sent into remote server are still running. That is not what I want, I just want to stop the ssh script together with ssh session's disconnection.

How can I stop the ssh scripts' running when the ssh session's end?

0 Answers
Related