Connecting to Windows Sandbox instance
ev-dev opened this issue · comments
Hey just found yet another one of your awesome modules here!
This is probably a silly question, but how can I connect to a Sandbox instance via local pwsh?
I have some automation working to install PSCore preview in the sandbox and enable remoting, but I'm having a hard time connecting to the Sandbox from my host powershell (also v7 core). I know there's a way I can run commands inside the sandbox from my local terminal/shell but I haven't had much [successful] experience with setting up WinRM/SSH servers.
I've tried a bunch of various options with Enter-PSSession
, but I'm just not passing the correct values for what I'm trying to do I think.
I've tried using the IP of the sandbox as reported by Get-NetIPAddress from within it, and then I tried using the -ComputerName param with the value of returned by hostname
ran in the sandbox.
Seemed like WinRM would be easier to get working compared to setting up OpenSSH server in the sandbox but either one would be okay, any thoughts?
PS. thanks for all the great OSS work you've contributed, I use bits of like 4-5 of your modules daily! You're certainly one of the most productive members of the PowerShell community I've come across :)
Also my apologies, I just realized this was more of a help ticket than a valid repo issue but I posted here because my Google-fu isn't turning up much useful information for this one
I never set up Discussions, so an issue is fine. I got remoting to work in Windows PowerShell between the host and the sandbox. I haven't tried PowerShell 7 or SSH. There are probably two steps you have to take. First, you need to add the IPAddress of the sandbox to TrustedHosts.
set-item WSMan:\localhost\Client\TrustedHosts -Value 172.* -Concatenate -force
Use whatever IP address you see in the container. Then you need to have admin rights. Since we don't know the password for the default account, create an admin account in the sandbox.
net user jeff PASSWORD /add
net localgroup administrators jeff /add
Then you can connect with credentials.
enter-pssession 172.29.73.178 -Credential jeff
Using ssh might be trickier, but I'm going to give that a try.