Página 1 de 1

[RESUELTO] Paquete para habilitar el servicio SSH en macOS

Publicado: 22 de noviembre de 2024 - 12:40 p. m.
por bastien30
Buen día,

He creado un paquete para habilitar el servicio SSH en máquinas macOS (probado solo en ARM); si es útil para otros, aquí está:

Código: Seleccionar todo

# -*- 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"
Tenga en cuenta que, de forma predeterminada, solo los usuarios con derechos de administrador pueden conectarse a través de SSH.

Re: [RESUELTO] Paquete para habilitar el servicio SSH en macOS

Publicado: 25 de noviembre de 2024 - 10:32 a. m.
por dcardon
Hola Bastien, ¡

gracias por compartir! Le he pasado el mensaje al equipo de empaquetado, que lo añadirá a su lista de tareas pendientes para la tienda. :-)

Hasta pronto,

Denis.