I have a python script on a machine.

I could run it from both **ssh connection** and the **console** of the machine.

Because the script changes some IP config stuff, I want to disconnect the ssh before doing the IP changing - that way the ssh won't hang and will be closed properly before the IP changes.

**So** - is there a way in python to check if the script is ran from ssh? and if so to close the ssh?