I have an ssh session and I'm running a script. I want to terminate the script without exiting the ssh session. If I run the script in a local PC, I press Ctrl+C and the script stops, while if I press Ctrl+C in remote session I close the ssh session itself (and also the script in this case). How can I stop the script in remote shell without interrupting the ssh connection?
I connect with the usual ssh user@ip
command,
in a standard Ubuntu distribution, using the Git Bash from Windows.
In my Windows client the .ssh/config
is as follows:
Host 192.168.XXX.YYY
HostName 192.168.XXX.YYY
User auser
ForwardAgent yes
Host 192.168.XXX.ZZZ
HostName 192.168.XXX.ZZZ
User auser
They are not related to the remote server that I'm using.
CTRL-Z
to put it into the background, then kill it? Although I am not sure whyCTRL-C
would kill the ssh session.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.ssh user@ip
, then I go manually to the folder where the python script is and I run it withpython3 myscript.py
. At this point the script is running, and if I try to stop it with Ctrl+C the session ends.myscript.py
is doing something in response to KeyboardInterrupt or a Ctrl-C INT signal, like killing the parent process.