klintkrossa
Posts: 81
Joined: Tue Nov 10, 2015 3:06 pm

More ssh questions

Thu Apr 13, 2017 4:30 pm

Hello,
I have two reason for this question.
Can python{3} force my ssh connection to close? From the Raspberry pi side.


ie. If there is a intruder I call a python command and it closes all but my connection.
ie2. I have python shell running when I log in. if I type exit() the raspberry pi just resets the python shell. if I type import Quit the ssh connection ends.
Thanks
This is not like any other bulletin boards that I have been on. Been flamed on other BB's so bad I was afraid to ask.

All my Raspberry Pi's are like the Hessian artilleryman of Sleepy Hollow.

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: More ssh questions

Fri Apr 14, 2017 7:36 pm

How would you know if there was an intruder ?
If there was such a function what would stop an intruder from using it to kick you out ?

The smart thing is to configure your system so its safe and you never have to think about doing such things.

There probably isn't any Python functions for doing what you are looking for because "sshd" is a system service and usually you dont want users programs to mess with system services.
However, If you are running as super-user (as user root or with sudo) then you have extra privileges that allow you to control system services. You can restart the sshd service for example, possibly closing all active ssh connections.
You could also go through the list of running processes and kill all the "bash" (shell) processes that isn't yours.

Return to “Python”