SSH process persistent but remote access closed
I have a problem programming on Solaris 10 and hope to ask for help here. I created a script to call the "ssh" binary. This script does some checks before running the "ssh" binary as a subprocess. The script takes the power of "root" with the SUID method.
After using this script for some time, some of the processes remain dangling as shown below.
root 23322 1 0 12:24:38? 0:00 scriptssh device321
I connected to device321 and couldn't find any other users existing on the device.
After some reading, I realize that the script has disconnected from the controlling terminal (look at "at" tty and 1 for "PPID") Is it a subprocess error in Python if I use the "communicate" method?
Does anyone have a way to resolve this or determine why this is happening?
The script is written in Python.
It might be easier to isolate the problem like this:
User A on remote server -> SSH session created
User. Logout of remote server -> SSH session remains
SSH session throws high cpu on current server.
Below are some code snippets.
def main(): .... .... try: if logic_user(username) == "privilege": if ip_check(src_ip,p_list): ssh_out(ssh_exe) else: print("You do not have access to SSH") except KeyboardInterrupt: print("Ctrl+c keyed in") finally: print("\nexiting ssh") def ssh_out(ssh_exe): cmd = subprocess.Popen(ssh_exe, shell=True) cmd.communicate()
source to share
No one has answered this question yet
Check out similar questions: