I have to admit that I was waiting for this for some time. Finally, PowerShell 6.0.0-Alpha_13 can do remoting between Windows to Linux. This is Awesome!
I’m going to give you the top-to-bottom scope in order to avoid going back-and-forth between link. So, it’s all here and including tips and print-screens.
Instructions for Windows OpenSSH installation
- First Download: https://github.com/PowerShell/Win32-OpenSSH/releases/tag/v0.0.4.0
- Unblocked zipfile and *extract contents to C:\Program Files\OpenSSH (You will need to create the folder). Start Powershell Open Source “Run as Administrator” and change folder to:
cd ‘C:\Program Files\OpenSSH’
- Install sshd and ssh-agent services by using the following command line:
powershell -executionpolicy bypass -file install-sshd.ps1
- Setup SSH host keys (this will generate all the ‘host’ keys that sshd expects when its starts).
- Open Firewall (Windows PowerShell 5.x) Server: (This command works in Windows 10)
New-NetFirewallRule -Protocol TCP -LocalPort 22 -Direction Inbound -Action Allow -DisplayName SSH
- Or for a Workstation:
netsh advfirewall firewall add rule name='SSH Port' dir=in action=allow protocol=TCP localport=22
- Then, to set sshd in auto-start mode and open up firewall:
Set-Service sshd -StartupType Automatic Set-Service ssh-agent -StartupType Automatic
- Edit the sshd_config file at the location where you installed Win32 Open SSH and make sure to enabled the following lines:
Also, add the following line to the Subsystem section:
Subsystem powershell C:/Program Files/PowerShell/220.127.116.11/powershell.exe -sshs -NoLogo -NoProfile
Finally, you must add the following line in the system path: “C:\Program Files\OpenSSH”
Failure to add this path line will cause the following error because it can’t execute sshd.exe:
If there’s a need to restart Windows SSHD services, just use the following PowerShell commands:
Stop-Service sshd Start-Service sshd
Instructions for Ubuntu SSH installation:
- Download using Ubuntu apt repository using sudo:
$ sudo apt install openssh-client $ sudo apt install openssh-server
- Make changed to Ubuntu sshd_config file to enabled some lines below:
$ sudo gedit /etc/ssh/sshd_config
- Again, make sure to enabled the following lines:
- Add the following line to the Subsystem section:
Subsystem powershell powershell -sshs -NoLogo -NoProfile
When done, in Ubuntu, just restart sshd service :
sudo service sshd restart
If you want to verify Ubuntu SSH is working, just type the following command:
ps -A | grep sshd
This should display a line showing sshd. If is blank, then is not on.
Connecting Linux to Windows
This is strange but, more likely, you will get an error the first time you try to connect. Just try the second try and it will work.
Enter-PSSession -Hostname earth2 -Username max_t
Connecting Windows to Linux
Again, I’ve seen the same behavior. It will fail the first time and the it will work.
Enter-PSSession -Hostname orion -Username maxt
After all have been tested, you can now connect from Windows to a Linux system. Then, you can execute your Linux commands from the Linux PowerShell session at your Windows Desktop. Is that amazing!!
Keeping things Simple!
This tips may not hurt to do:
1. winrm quickconfig
2. Run the ./InstallPsRemoting.ps1
Also, if you don’t have a domain set up, then set a workgroup environment, and adding the IP-Addresses, computer names for either Windows and Linux host file:
In Windows the *hosts file can be found under “C:\Windows\System32\Drivers\etc“, and in Linux Ubuntu can be found under “/etc/hosts“.
The editors need to be open “Run as Administrator” in order to make changes to this file. In Windows, open Powershell “Run as Administrator” the execute notepad:
In Linux, use the sudo then the editor of choice;
sudo gedit /etc/hosts
I’m hoping this information will get you all going in doing PowerShell Remoting between Windows and Linux.
Additional Resource Information
OpenSSH Instructions at:
For Ubuntu questions: