From the course: Learning PowerShell Core

PowerShell remoting on Linux - PowerShell Tutorial

From the course: Learning PowerShell Core

Start my 1-month free trial

PowerShell remoting on Linux

- [Instructor] PowerShell remoting needs a way to connect to remote Linux systems, and uses the SSH protocol to do that. Open SSH is a package many use to create an SSH daemon on a remote system so clients can connect to it. Using SSH, Powershell remoting both as Windows and Linux as a client can connect to a remote systems. PowerShell remoting leverages the SSH protocol to manage that connection. You'll see in the upcoming demo how we can setup PowerShell remoting and SSH to connect to and from Windows and Linux systems. So I've now SSH'd into my Ubuntu Linux machine and I have already installed PowerShell core from the previous module that we went over. So first thing I need to do is I need to make sure that the open SSH server is installed and up to date. Now it's probably going to be installed by default since it is Linux after all, but what I can do is I'll use the apt command here and just make sure I have the latest version. All right so it looks like we're already at the latest version so that's fine, we have open SSH. Next up, we need to modify a configuration files. That configuration file is etc/ssh/sshd_config, and in here you can modify this with any text editor. You can emaxx, VI, vim, whatever, I'm just using VI in this case. What we have to do is we have to scroll down and add a subsystem, so we need to make sure that OpenSSH knows where to find PowerShell. So we'll first add the PowerShell subsystem in here by providing Subsystem powershell, the path for the PowerShell executable which is, pwsh -NoLogo -NoProfile, so this essentially allows OpenSSH to initiate a PowerShell session. There's a couple other commands we also need to do. The first one is password authentication since I'm not going to be setting up certificate based authentication. I need to make sure that password authentication is enabled, and looks like it is now so we do have password authentication set to yes, which is completely fine. So that's all we need to do to set up OpenSSH. I'll go ahead and close that and write that to disc. And now we need to make OpenSSH recognize that the configuration file was changed, and I will restart the SSH daemon. Now that it's restarted everything should work, let's hope so. We haven't actually ran this through all the way through but we'll see. So now that I have that configured, I can exit out and now I'm back in my PowerShell core session on my Windows 10 machine. So now let's try it out. I have a dollar Linux machine variable in here and this should be the IP address. Actually let's not even use that for this instance. Let's just change that to the IP address that I know it is, which is 10.0.0.5. UserName is adam, that is local username on my Linux machine and I'm just going to be calling host name which should bring back just the host name, let's see if this works. Okay it's going to prompt me for my password since I didn't provide a credential. And voila, it worked. So we have PowerShell remoting set up from Windows to Linux.

Contents