玩蛇網推薦圖文教程:python 清單
Linux手動拒絕SSH登陸使用者的代碼,供有需要的朋友參考。
什麼情況下需要用Linux手動拒絕SSH登陸使用者呢?特别是在一些生産平台或者做安全審計工作時,會發現許多使用者SSH連接配接到同一台伺服器,或是沒有關閉程序還駐留在系統内。
限制SSH連接配接數與手動斷開空閑連接配接也有必要之舉,這裡寫出Linux下手動剔出其他使用者的過程。
1、檢視系統線上使用者:
[[email protected] ~]# w
14:30:26 up 38 days, 21:22, 3 users, load average: 0.00, 0.01, 0.05
USER TTY FROM [email protected] IDLE JCPU PCPU WHAT
root pts/0 162.16.16.155 14:30 0.00s 0.07s 0.05s w
root pts/1 162.16.16.155 14:30 12.00s 0.01s 0.01s -bash
root tty1 :0 05Dec13 38days 2:16 2:16 /usr/bin/Xorg :0 -nr -verbose -audit 4 -auth /var/run/gdm/auth-for-gdm-LrK8wg/database -noliste
2.檢視哪個屬于此時自己的終端(我開了兩個連接配接)
[[email protected] ~]# who am i
root pts/0 2013-12-31 14:30 (162.16.16.155)
3.pkill掉自己不适用的終端:[[email protected] ~]# pkill -kill -t pts/1
4.檢視目前終端情況
[[email protected] ~]# w
14:31:04 up 38 days, 21:23, 2 users, load average: 0.00, 0.01, 0.05
USER TTY FROM [email protected] IDLE JCPU PCPU WHAT
root pts/0 162.16.16.155 14:30 0.00s 0.04s 0.01s w
root tty1 :0 05Dec13 38days 2:16 2:16 /usr/bin/Xorg :0 -nr -verbose -audit 4 -auth /var/run/gdm/auth-for-gdm-LrK8wg/database -noliste
[[email protected] ~]#
Linux手動拒絕SSH登陸使用者的設定,如果最後檢視還是沒有幹掉,建議加上-9 強制殺死。[[email protected] ~]# pkill -9 -t pts/1
玩蛇網文章,轉載請注明出處和文章網址:https://www.iplaypy.com/linux/l6876.html
相關文章 Recommend