hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.19k stars 4.43k forks source link

Support `vagrant powershell` from Mac/Linux hosts #7849

Open MikaelSmith opened 7 years ago

MikaelSmith commented 7 years ago

I'd like to be able to use Powershell remoting (via the vagrant Powershell command) to access Windows machines (particularly Nano Server images) from a Mac or Linux host. Currently the powershell plugin is limited to Windows.

Techienaut commented 7 years ago

@MikaelSmith WARNING, this is probably not "secure" method (hopefully someone can suggest a better one). But if your goal is to connect to a Windows machine, try installing chocolatey on the Windows host, then install openssh https://chocolatey.org/packages/openssh. Read the docs, but trying: choco install openssh -params '"/SSHServerFeature"'

This will configure the sshd server, for the most-part.

NOW THIS IS WHERE IT'S NOT SECURE, but to get it working, open Programfiles/sshd_config and set the flags to: PermitRootLogin yes StrictModes no Compression no -- btw I'm sure setting RSA or Public Key is more advisable, but this at least got me running :) -- Needless-to-say already have a "vagrant" windows user w/ admin privilages... vagrant ssh (enter username and password). > open powershell.exe during session should work.

LukeCarrier commented 7 years ago

Ouch, I just ran in to this one :fearful:

It's worth noting that PowerShell is now available for Linux.

I've not tested remoting support from a Linux host, but I'm happy to have a go at implementing this. Looking at the powershell and ssh commands, it appears the most correct way to accommodate multiple platforms would be to move the Windows host's PS capabilities to VM actions. Adding the capabilities to the Linux host would result in duplication. Any opinions?

berney commented 7 years ago

There is a go package for a WinRM CLI, https://github.com/masterzen/winrm-cli. If you install it, if you get the IP address (on a bridge network), or setup a NAT port-forwarding rule (on a NAT network) you can then run remote commands via winrm ipconfig. It defaults to localhost port 5985, user vagrant, password vagrant (no SSL).

It's not a full shell, you only run individual commands. It would be nice if a full shell was available like when you powershell from Windows or when you SSH in. And it would be extra nice if Vagrant could leverage this on all client platforms.

vors commented 5 years ago

Any updates on this one? Cross-platform pwsh is available for few years already.