C7 d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlm Z d dl
mZ d dlm
Z
ee ZdZdZ ed Z ed Zd
ZddZddZddefdZdS ) N) getLogger)URLError)Path)atomic_rewritezFhttps://repo.imunify360.cloudlinux.com/defense360/assisted-cleanup.pubz!clsupport@sshbox\.cloudlinux\.comz/etc/ssh/sshd_configz/etc/ssh/sshd_config.dc 6 K d} t g}t r:| t t d t
| D ]} | D ]}| }|
d r]|
d sH t | d } | c c | c S # t t f$ r Y w xY w# t $ r*}t d| d| Y d}~d}~ww xY wn4# t$ $ r'}t d | Y d}~nd}~ww xY w| S # | c cY S xY w)
z
Detect SSH port from config and its overrides.
Searches configs in reverse order to find the last override first.
z*.confPort # Failed to read : NzFailed to get SSH port: )SSH_CONFIG_PATHSSH_CONFIG_DIRexistsextendsortedglobreversed read_text
splitlinesstrip
startswithintsplit
IndexError
ValueErrorIOErrorloggerwarning Exception)portconfig_filesconfig_filelinees R/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/utils/sshutil.pyget_ssh_portr' s
D'( "" G~':':8'D'D E EFFF $L11 K
'1133>>@@ % %D::<