Alejandro Trujillo, Información y Tecnologías Ecuador

Oracle, Microsoft, Administración, y algo más

Introducción y Configuración Básica de WinRM

WinRM (Windows Remote Management) es una herramienta que nos permite administrar el Hardware de computadores basados en Windows Vista y de Servidores basados en Windows Server 2008 tanto de forma local como remota. WinRM está basado en el protocolo WS-Management (Web Services Management que es un protocolo basado en SOAP – Arquitectura Orientada a servicios – diseñado para localizar e intercambiar información de adminsitración mediante la interoperabilidad y consistencia entre sistemas de diferentes fabricantes de Hardware y diferentes sistemas operativos. El estándar forma parte del «Distributed Management Task Force» )

Componentes

  • WinRM Scripting API – Permite obtener datos desde computadores remotos usando Scripts que ejecuten operaciones basadas en el protocolo WS Management
  • Winrm.cmd – Herramienta basada en CLI (Command Line Interface) que permite la configuración de WinRM, manejar sus recursos y  obtener datos
  • Winrs.exe – Herramienta de línea de comandos que permite ejecutar remotamente la mayoría de comandos cmd.exe usando el protocolo WS Management
  • WMI Service –  Servicio que habilita la implementación de Clases WMI para la obtención de datos de Hardware locales
  • ITPMI (Intelligent Platform Management Interface ) – Interfase para controlar y diagnosticar hardware en un servidor remoto  mediante controladores de adminsitración de base (baseboard management controllers  BMCs)

Configuración de un shell remoto

Windows Vista y Windows Server 2008 tienen dos comandos para la gestión basada en WS Management: WinRM y WinRS. WinRM se encarga de la configuración del servidor y de servidores remotos mientras que WinRS es el cliente para la ejecución de comandos.  Primero, lo que debemos hacer es configurar el servidor con WinRM para ejecutar comandos desde otro equipo; para esto seguimos los siguientes pasos:

  1. Iniciar CMD (Con privilegios de admistrador)  
  2. Escribimos la instrucción winrm quickconfig
    C:\Windows\system32>winrm quickconfig
    WinRM is not set up to allow remote access to this machine for management.
    The following changes must be made:
    Set the WinRM service type to delayed auto start.
    Start the WinRM service.
    Create a WinRM listener on HTTP://* to accept WS-Man requests to any IP on this
    machine.
    Enable the WinRM firewall exception.
    Make these changes [y/n]?
  3. Cuando nos pregunte si deseamos aplicar los cambios escribimos Y
    Make these changes [y/n]? yWinRM has been updated for remote management.WinRM service type changed successfully.
    WinRM service started.
    Created a WinRM listener on HTTP://* to accept WS-Man requests to any IP on this
     machine.
    WinRM firewall exception enabled.
    WinRM has been updated for remote management.WinRM service type changed successfully.
    WinRM service started.
    Created a WinRM listener on HTTP://* to accept WS-Man requests to any IP on this
     machine.
    WinRM firewall exception enabled.

Esta configuración winrm quickconfig realiza tres operaciones:

  • Inicializa el servicio WinRm y configura su modo de inicio en Automático
  • Configura un Listener para los puertos que envían y reciben mensajes WS Management mediante HTTP
  • Define excepciones del Firewall para habilitar el servicio WinRM y abre los puertos 80 o 443 (Dependiendo de la configuración del Listener)

Por defecto winrm quickconfig configura el Listener para usar HTTP en el puerto 80 TCP, sin embargo se puede utilizar también HTTPS en el puerto 443. Para esto se usa el comando
winrm quickconfig -transport:https

Hay que tener en cuenta que si se usa HTTPS se debe disponer de un certificado SSL valido emitido por una Entidad Emisora de Certificados de Autorización (CA), ya que WINRM no permite el uso de certificados autofirmados.

Ahora ya tenemos habilitada la conexión. Es posible ver la configuración del listener usado mediante el comando winrm enumerate winrm/config/listener  que nos dará información de transporte, puerto, lista de dirección habilitadas, etc.

C:\Windows\system32>winrm enumerate winrm/config/listener
Listener
    Address = *
    Transport = HTTP
    Port = 80
    Hostname
    Enabled = true
    URLPrefix = wsman
    CertificateThumbprint
    ListeningOn = 10.1.63.154, 127.0.0.1, 169.254.94.20, 169.254.137.184, ::1, f
e80::100:7f:fffe%8, fe80::5efe:10.1.63.154%24, fe80::8f2:f797:9eed:5e14%23, fe80
::5c2f:b279:b97a:5f6c%11, fe80::fd10:fbb3:c6aa:89b8%12

El comando winrm get wmicimv2/win32_service?Name=WinRM   comprueba la configuración del servicio WINRM mediante WMI

C:\Windows\system32>winrm get wmicimv2/win32_service?name=winrm
Win32_Service
    AcceptPause = false
    AcceptStop = true
    Caption = Windows Remote Management (WS-Management)
    CheckPoint = 0
    CreationClassName = Win32_Service
    Description = Windows Remote Management (WinRM) service implements the WS-Ma
nagement protocol for remote management. WS-Management is a standard web service
s protocol used for remote software and hardware management. The WinRM service l
istens on the network for WS-Management requests and processes them. The WinRM S
ervice needs to be configured with a listener using winrm.cmd command line tool
or through Group Policy in order for it to listen over the network. The WinRM se
rvice provides access to WMI data and enables event collection. Event collection
 and subscription to events require that the service is running. WinRM messages
use HTTP and HTTPS as transports. The WinRM service does not depend on IIS but i
s preconfigured to share a port with IIS on the same machine.  The WinRM service
 reserves the /wsman URL prefix. To prevent conflicts with IIS, administrators s
hould ensure that any websites hosted on IIS do not use the /wsman URL prefix.
    DesktopInteract = false
    DisplayName = Windows Remote Management (WS-Management)
    ErrorControl = Normal
    ExitCode = 0
    InstallDate = null
    Name = winrm
    PathName = C:\Windows\System32\svchost.exe -k NetworkService
    ProcessId = 1704
    ServiceSpecificExitCode = 0
    ServiceType = Share Process
    Started = true
    StartMode = Auto
    StartName = NT AUTHORITY\NetworkService
    State = Running
    Status = OK
    SystemCreationClassName = Win32_ComputerSystem
    SystemName = CC-C5-C0-3E-E1
    TagId = 0
    WaitHint = 0

Por último el comando winrm get winrm/config mostrará información relacionada con la configuración de WinRM

C:\Windows\system32>winrm get winrm/config
Config
    MaxEnvelopeSizekb = 150
    MaxTimeoutms = 60000
    MaxBatchItems = 20
    MaxProviderRequests = 25
    Client
        NetworkDelayms = 5000
        URLPrefix = wsman
        AllowUnencrypted = false
        Auth
            Basic = false
            Digest = true
            Kerberos = true
            Negotiate = true
            Certificate = true
        DefaultPorts
            HTTP = 80
            HTTPS = 443
        TrustedHosts
    Service
        RootSDDL = O:NSG:BAD:P(A;;GA;;;BA)(A;;GR;;;ER)S:P(AU;FA;GA;;;WD)(AU;SA;G
WGX;;;WD)
        MaxConcurrentOperations = 100
        EnumerationTimeoutms = 60000
        MaxConnections = 5
        AllowUnencrypted = false
        Auth
            Basic = false
            Kerberos = true
            Negotiate = true
            Certificate = false
        DefaultPorts
            HTTP = 80
            HTTPS = 443
        IPv4Filter = *
        IPv6Filter = *
    Winrs
        AllowRemoteShellAccess = true
        IdleTimeout = 900000
        MaxConcurrentUsers = 5
        MaxShellRunTime = 2147483647
        MaxProcessesPerShell = 5
        MaxMemoryPerShellMB = 80
        MaxShellsPerUser = 2

Para hacer cambios en la configuración de WinRM se usa la palabra SET seguido del parámetro (URI/elemento de administración) seguido de @ y entre llaves CLAVE=»VALOR» por ejemplo

winrm set winrm/config/service @ {IPv4Filter=»192.168.1.100-192.168.1.200″}
winrm set winrm/config @{MaxEnvelopeSizekb=»100″}

diciembre 9, 2008 Posted by | Windows Server 2008 | , , , , , , , | Deja un comentario