[RISOLTO] Pacchetto per abilitare il servizio SSH su macOS
Pubblicato: 22 novembre 2024 - 12:40
Buongiorno,
Ho creato un pacchetto per abilitare il servizio SSH sui computer macOS (testato solo su ARM); se può essere utile ad altri, eccolo qui:
Si noti che per impostazione predefinita, solo gli utenti con diritti di amministratore possono connettersi tramite SSH.
Ho creato un pacchetto per abilitare il servizio SSH sui computer macOS (testato solo su ARM); se può essere utile ad altri, eccolo qui:
Codice: Seleziona tutto
# -*- coding: utf-8 -*-
from setuphelpers import *
uninstallkey = []
def get_ssh_status():
# Return True if enabled, False if disabled
status = run(r'systemsetup -getremotelogin')
if r'Remote Login: On' in status:
return True
else:
return False
def install():
print(r'Enabling SSH service...')
if not get_ssh_status():
ret = run(r'systemsetup -setremotelogin on', accept_returncodes=[0, 1])
if ret != r'':
print(r'Error enabling SSH service, see reason below !')
error(ret)
else:
if get_ssh_status():
print(r'SSH service successfully enabled.')
else:
error(r'SSH service not enabled, check workstation for misconfiguration !')
else:
print(r'SSH service already enabled.')
def uninstall():
if get_ssh_status():
ret = run(r'systemsetup -f -setremotelogin off')
if get_ssh_status():
print(r'Error disabling SSH service, see reason below !')
error(ret)
else:
print(r'SSH service successfully disabled.')
else:
print(r'SSH service already disabled.')
def audit():
if not get_ssh_status():
print(r'SSH service not enabled, reinstalling package...')
install()
return "WARNING"
else:
print(r'SSH service enabled.')
return "OK"