From a9f7a47022589fdea2327bdaf74e8aadb50e05ee Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 3 Mar 2019 10:57:39 +0800 Subject: [PATCH] Update __init__.py --- route/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/route/__init__.py b/route/__init__.py index eba022bfb..f2fc83db8 100755 --- a/route/__init__.py +++ b/route/__init__.py @@ -235,7 +235,21 @@ def create_rsa(): public.execShell('chmod 600 /root/.ssh/authorized_keys') +def clear_ssh(): + sh = ''' +#!/bin/bash +PLIST=`who | grep localhost | awk '{print $2}'` +for i in $PLIST +do + ps -t /dev/{$i} |grep -v TTY|awk '{print $1}' | xargs kill -9 +done +''' + if not public.isAppleSystem(): + public.execShell(sh) + + def connect_ssh(): + clear_ssh() global shell, ssh if not os.path.exists('/root/.ssh/authorized_keys') or not os.path.exists('/root/.ssh/id_rsa') or not os.path.exists('/root/.ssh/id_rsa.pub'): create_rsa()