Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 3
    What about CTRL-Z to put it into the background, then kill it? Although I am not sure why CTRL-C would kill the ssh session. Commented Feb 3, 2022 at 19:00
  • It's strange that Ctrl-C closes the ssh session. I never experienced this, pressing Ctrl-C in a ssh session always worked correctly for me, ie. did break the command running in the ssh session, but didn't exit the session. You must have configured something in a quite nonstandard way... Commented Feb 3, 2022 at 19:02
  • 3
    What exact local command (ssh …) do you use to connect? Does the command give you an interactive shell and then you run the script by hand? How exactly do you run it? Are there any custom settings in your (local) ~/.ssh/config and/or /etc/ssh/ssh_config that apply to the connection? What is your local OS? What is the remote OS? Please edit the question and be specific. Commented Feb 3, 2022 at 19:08
  • @KamilMaciorowski I connect to remote server by using ssh user@ip, then I go manually to the folder where the python script is and I run it with python3 myscript.py. At this point the script is running, and if I try to stop it with Ctrl+C the session ends. Commented Feb 3, 2022 at 19:46
  • You say you logged into the shell and then started the script, its easy to write an example (with either shell or python) to show this is not normal behavior. Sounds to me like maybe that myscript.py is doing something in response to KeyboardInterrupt or a Ctrl-C INT signal, like killing the parent process. Commented Feb 3, 2022 at 22:13