Now, another option that we've got is instead of using the standard
Enable‑PSRemoting and QuickConfig, we can utilize SSH. Now,
of course,
remember the two ways of communicating are the HTTP and
the HTTPS, which is the standard ones,
which is also mapped into some TCP ports, but let's say I wanted to prepare
the Windows 10 environment, for example, to be able to do SSH remoting. So
what we can do is I'm going to flick back to the Windows 10 machine now so
that we can execute some commands there. So we're back on the client. I'm just
going to clear the screen here.
Now what we can do is in order to enable this,
we need to add some specific capabilities to the Windows 10 device. So we
can do this by adding some Windows capabilities, so I'm going to add what's
called the OpenSSH.Client, and then what I'll do is do the same one again,
but this time I'm going to say .Server,
oh I've got too many dots there, but I'm going to say
.Server and add the server to it as well.
Okay, so we have both clients now installed.
What I'm then going to do is use PowerShell to actually go ahead and
set the service, which would be the SSH service.
So you can see I'm doing Set‑Service sshd, and set that to Automatic.
Now notice what happens.
It says, well that service doesn't exist and it wasn't
found on the server. So that's good.
So we can go to Services here,
we can then go into the Services itself, and we'll change it to the
standard one just because it's easier to read, and then we can scroll
all the way down looking for that specific service to see whether
that service has been installed.
Now, of course, if that service doesn't display and isn't listed here,
then that will mean that probably the environment needs to be
rebooted before we can actually start that service.
So I'm just going to reboot my machine, and then we'll connect back and ensure
that the service is started. So our machine is rebooted, so let me launch my
console again, Windows Terminal, Run as administrator.
We'll make that full screen, zoom in a little bit, and then we'll
clear. Okay, and next thing is to start the service to make sure
that it actually runs, sshd, okay.
And I'm going to set the service to actually be Automatic, like we tried
to last time, ‑StartupType, and we'll say Automatic.
Okay, so we've set it to be automatic now. Now that we have that configured,
so we have that running, now what we can do is I can then on this machine,
I can then say Install‑Module.
And then what we have available to us is we have the
Microsoft.PowerShell.RemotingTools module available to us. So we
can install the module, we can then import the module. Now of
course we have to make sure it's the right version of PowerShell,
so I'm using the Windows PowerShell.
You'll notice in my terminal here I've got the drop‑down that says Windows,
and you've got Command Prompt and PowerShell. First thing, obviously, is I'm
trying to get it from a NuGet package, so I need to kind of update the
provider. This will then go and make sure that works,
then it will validate that, and then if my
Microsoft.PowerShell.RemotingTools module is available,
then it will try to download that too. So we'll give
it a second to complete. Okay, same thing again, I'd like to add that again,
press Yes. Okay, it's gone to the PSGallery, and now we installed it.
So I'm going to change from my Install here to Import,
so I'm going to import that module. Now, of course, notice when it comes
back it says the version of PowerShell on this computer is blah and you
need to have a more up‑to‑date version, which is version 6.0,
which is perfectly fine.
So we'll need to update our PowerShell or what we could do
here is simply just go to PowerShell, which is PowerShell 7.0 at this point,
which I think this is the latest version, there we go,
7.13, and what I can do is go and say Import‑Module, go
over to here like so. You can import it.
So because I'm using a newer version of PowerShell in this window,
it lets me import.
So then at this point I can say Enable. Now remember how we used
PSRemoting, I now get to use something called Enable‑SSHRemoting. And
if I look at the extra kind of tab options,
you can see I've got a few different configuration
options, as well as some other entries.
So I'm going to say Verbose, press Enter, and then notice what it does.
You can see it's checking the Platform information,
it's going to validate any of the configuration, and now it's
going to go ahead and try to configure that one.
It creates the configuration file that contains the entries that are needed.
I'm going to say Yes to enable that service, and now it says, okay,
it's created it, it's ready to go, and now we need
to restart the service itself.
So I'm going to say Restart‑Service ‑name, and then
sshd, so the service will get restarted.
Now, that means that we have configuration information ready. There's
a config file. So if I just take this value here,
I'm actually just going to launch my window. Let me just go into the C drive,
and I'm going to change my view so I can see hidden ones,
go to ProgramData. You'll see when I go to ProgramData we can
go to ssh, and then if I move across here,
ssh_config. If I just right‑click here,
choose Open With. I'm going to choose Notepad, and then open
it, and then we'll make it a little bigger.
You can see that we have the port details,
the listener information,
you'll see Authentication, and some of the basic bits and pieces
that are configured for SSH. What that means is that I'm now able to
SSH for Windows 10. So I can then say, well, here's the latest version,
use any of the ssh clients that I want to use,
whether I'm using, you know,
some of the third‑party tools or another Windows device to get to it,
but I can now SSH directly to this machine as part of that.
So, enabling PowerShell remoting can be done in various different ways.
The first way, obviously, that we saw was to use
setting the WSMan configuration,
which is a QuickConfig way of doing it, or it could be
done using installing modules, using SSH or it can be done by doing Enable‑PSRemoting.