PDQ.com mobilePDQ.com desktop
Support

Configuring PowerShell Core 6 For Your Environment

Jordan HammondJordan Hammond
·

PowerShell Core 6

There are several reasons that you may want to use PowerShell Core 6. Some people like bigger numbers and 6 is definitely bigger than 5. Others may have some Linux machines in their environment and would prefer to use PowerShell’s object-oriented goodness when interacting with it.

No matter your reasons for it, the first thing you have to do is get it configured for your environment. Join me while we go on an adventure to discover the requirements and set up steps that allow you to remote into your Linux machines from a PowerShell console.

Before we get started we need to point out that while PowerShell Core 6 adds cross-platform functionality, it is different from Windows PowerShell 5.1. As it currently stands, it has significantly less functionality. This is a great tool to help you control other operating systems in your environment, but for your day to day Windows tasks, Windows PowerShell 5.1 is still your best bet.

Setting Up Linux

Installing PowerShell Core 6 for Linux

PowerShell Core is published to package repositories, so installing it is pretty straightforward.

1. First, import the public repository GPG keys

curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add

2. Then, register the Microsoft Ubuntu Repository, this makes updating to future releases easier

curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list

3. Next, update the list with the newest versions of the packages

sudo apt-get update

4. Install PowerShell

sudo apt-get install -y powershell

Setting Up OpenSSH

Now that we have PowerShell installed we need to set up OpenSSH to allow it to use PowerShell for ssh connections.

1. Modify the config file

Sudo Nano /etc/ssh/sshd_config

2. Add the following line below any existing subsystem lines in the document

Subsystem powershell /usr/bin/pwsh -sshs -NoLogo -NoProfile

3. Restart the sshd service

sudo service sshd restart

Linux is now all set up to allow ssh from PowerShell Core 6.

Setting Up Windows

Installing PowerShell Core 6 for Windows

  1. Download the latest release from here.

  2. Run the msi

  3. Follow all of the prompts

Installing OpenSSH

1. First, download the latest release by clicking here.

2. Then, extract all the contents to “C:\Program Files\OpenSSH”

3. From an elevated console run:

PowerShell.exe -ExecutionPolicy bypass -File “C:\Program Files\OpenSSH\install-sshd.ps1”

4. Press “Win” + “R” and type SystemPropertiesAdvanced

5. Click on Environment Variables Button

6. Highlight Path from system variables and click Edit

7. Add a line for C:\Program Files\OpenSSH\

Note: (adding this requires you to log out and back in for it to work)

Optional: Allowing ssh into your Windows machine

With this setup, you will be able to ssh into your Linux machine, but machines will not be able to ssh into your Windows box. If you would like it to work all around you will need to make three changes.

1. First, add a firewall rule to allow TCP over port 22. Run the following from an elevated PowerShell window

“netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP localport=22”

2. Then, open file “C:\ProgramData\ssh\sshd_config” in Notepad

3. After, add the following line below any existing subsystem lines in the document. Replacing with the version of PowerShell that you installed

Subsystem powershell c:\program files\powershell\\6.0.2\pwsh.exe

4. Finally, restart the sshd service

Use SSH With PowerShell

All set! You can test it out with either:

Invoke-Command or Enter-Pssession

Invoke-Command -Hostname (Hostname or IP) -UserName (Username) -ScriptBlock {script}

 

Enter-PsSession -Hostname (Hostname or IP) -Username (Username)

You’re Done!

Now, you have the power and knowledge to use PowerShell Core 6!  You can continue to use Linux through putty or something like an animal, or you can be the first in your company to jump into the FUTURE!

Watch our latest video about this topic for more helpful information.

Ready to put the PowerShell Scanner through its paces?

Take our 14-day Free Trial. Feel the power of the PowerShell scanner.
Start a Trial

Don't miss the next post!

(CVE-2020-1472) 'ZeroLogon' Vulnerability

The Zerologon Vulnerability Allows Attackers To Completely Take Over Your Domain Controller Without Credentials.

PDQ.com
© 2020 PDQ.com Corporation

Products

  • PDQ Deploy
  • PDQ Inventory
  • PDQ Link
  • Enterprise SL
  • Pricing
  • Downloads
  • Licensing
  • Buy