我正在尝试从我的 OS X 机器连接到新启动的 AWS EC2 Windows Nano Server。
我正在 OSX 上运行 powershell,并且按照这些说明
PS /Users/alex/Projects> $ip = "ec2-x-x-x-x.eu-west-1.compute.amazonaws.com"
PS /Users/alex/Projects> Set-Item WSMan:\localhost\Client\TrustedHosts $ip
Set-Item : Cannot find drive. A drive with the name 'WSMan' does not exist.
At line:1 char:1
+ Set-Item WSMan:\localhost\Client\TrustedHosts $ip
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (WSMan:String) [Set-Item], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetItemCommand
我尝试忽略这个问题并继续执行剩下的两个步骤:
PS /Users/alex/Projects> $user = "$ip\Administrator"
PS /Users/alex/Projects> Enter-PSSession -ComputerName $ip -Credential $user
Windows PowerShell credential request
Enter your credentials.
Password for user ec2-x-x-x-x.eu-west-1.compute.amazonaws.com\Administrator: ********************************
Enter-PSSession : MI_RESULT_ACCESS_DENIED
At line:1 char:1
+ Enter-PSSession -ComputerName $ip -Credential $user
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (ec2-x-x-x-x...e.amazonaws.com:String) [Enter-PSSession], PSInvalidOperationException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
答案1
请参阅 macOS 的 powershell 已知问题列表: https://github.com/PowerShell/PowerShell/blob/master/docs/KNOWNISSUES.md#remoting-support
初始包不支持 Linux/macOS 的客户端远程控制。这项工作正在 psl-omi-provider repo 中完成。
答案2
您想要交互式 shell 登录吗?如果是这样,为什么不从 Mac OS X 终端使用 ssh?命令如下:
ssh -i ~/.ssh/文件名.pem[电子邮件保护]
可以按照以下说明创建 pem 文件:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html