Pagina 1 di 1

[RISOLTO] Pacchetto per abilitare il servizio SSH su macOS

Pubblicato: 22 novembre 2024 - 12:40
di bastien30
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:

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"
Si noti che per impostazione predefinita, solo gli utenti con diritti di amministratore possono connettersi tramite SSH.

Re: [RISOLTO] Pacchetto per abilitare il servizio SSH su macOS

Pubblicato: 25 novembre 2024 - 10:32
di dcardon
Ciao Bastien,

grazie per la condivisione! Ho inoltrato il messaggio al team addetto al packaging, che lo aggiungerà alla lista delle cose da fare per il negozio. :-)

A presto,

Denis