Используя PowerShell версии 6.0.2 на Centos 7, пытаюсь получить сеанс на Windows 2012 Server. Делаем следующее:
$secpasswd = ConvertTo-SecureString "password" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ("domain\username", $secpasswd)
Enter-PSSession -ComputerName Some-Host-Name -port 5985 -Credential $mycreds
Получение следующей ошибки:
Enter-PSSession : MI_RESULT_ACCESS_DENIED At line:1 char:2
+ Enter-PSSession -ComputerName Some-Host-Name -port 5985 -Credential $m ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Some-Host-Name :String) [Enter-PSSession], PSInvalidOperationException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
Должен получить сеанс на машине Windows.
Выполните следующие действия, чтобы машина Windows доверяла машине centos
Set-Item WSMAN:\Localhost\Client\TrustedHosts -Value * -Force
Есть идеи, что мне нужно делать?
@ TheIncorrigible1 Да. Выполните следующую команду: Set-Item WSMAN: \ Localhost \ Client \ TrustedHosts -Value * -Force
Вы сделали это с обеих сторон?
@ TheIncorrigible1 1. Почему centos должен добавлять машину Windows в список доверенных, если он пытается подключиться? 2. Как мне это сделать?
Потому что это конфигурация клиента, а не конфигурация сервера. В этом случае ваш CentOS является клиентом. Вы можете сделать это так же, как и со своим Windows.
@ TheIncorrigible1 Добавил всю конфигурацию в файл etc \ hosts.allow, все та же ошибка
Вам следует запустить Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value *
. Не знаете, почему вы изменили файл hosts
@ TheIncorrigible1 Этой команды нет в Centos ...
PowerShell Core не поддерживает Set-Item
или привод WSMan:
в Linux? Если это так, у меня нет знаний, чтобы помочь мне в дальнейшем.
Вам необходимо использовать SSH для удаленного доступа с Linux на Windows. Это описано на сайте документации MS.
PowerShell Remoting Over SSH
Overview
PowerShell remoting normally uses WinRM for connection negotiation and data transport. SSH was chosen for this remoting implementation since it is now available for both Linux and Windows platforms and allows true multiplatform PowerShell remoting. However, WinRM also provides a robust hosting model for PowerShell remote sessions which this implementation does not yet do. And this means that PowerShell remote endpoint configuration and JEA (Just Enough Administration) is not yet supported in this implementation.
Getting Started with PowerShell Core on Windows, Mac, and Linux What do I need?
To get started with PowerShell Core you want to install and configure these three items on your operating system(s) of choice: • PowerShell Core 6 Beta • OpenSSH • Visual Studio Code
I was surprised how quickly I was up-and-running following the installation instructions. Each process involved relatively little tweaking for a beta experience.
If you are a Linux person you might be thinking, “OK. I already have OpenSSH installed.” Please read the OpenSSH link above for the step of editing the sshd_config file for PowerShell remoting support.
Or see also these answers:
Managing Windows Powershell from Linux terminal
https://serverfault.com/questions/638659/managing-windows-powershell-from-linux-terminal
How to Setup Linux to Query Windows WinRM Hosts
http://www.tomsitpro.com/articles/setup-linux-to-query-windows-winrm-hosts,1-3468.html
Есть ли у вашего хоста CentOS хост Windows в списке TrustedHosts? В противном случае они должны находиться в одном домене, используя Kerberos для аутентификации / авторизации.