A few steps to easily build a Windows SSH server

A few steps to easily build a Windows SSH server

The SSH mentioned here is called Security Shell. I believe that students who often use Linux will not be unfamiliar with it. The most common use of SSH is to remotely log in to the command line interface of other systems. Of course, it is mainly used by Linux users. But in fact, Windows 10 now comes with OpenSSH function, so we can install and use SSH related functions under Windows. Let's see how to install it.

Check the system version

First, make sure your system is Windows 10 1809 or later. If not, update the system to the latest status.

It is also very simple to check the system version. Open the Start menu, select Settings, then select System->About, and you can find the system version number at the bottom.

Alternatively, if you prefer the command line, you can also run the following command from PowerShell to check the version number.

(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").ReleaseId

Install OpenSSH

After determining the version number, let's install OpenSSH. The installation method is also very simple. Enter Windows Settings from the Start menu again. This time select Apps -> Apps & Features -> Optional Apps -> Add Features to enter.

Then find the OpenSSH server and client and install them.

If you like the simplicity of command lines, it is just as simple. Run the following command to check the OpenSSH function.

# Check the software first Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'

# The following output should be displayed. Note that the version number may change in the future. When installing, pay attention to Name: OpenSSH.Client~~~~0.0.1.0
State : NotPresent
Name: OpenSSH.Server~~~~0.0.1.0
State : NotPresent

Then just install them.

# Install the client Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

# Install the server Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

# Their output should be similar to the following Path:
Online : True
RestartNeeded : False

The result is exactly the same as the graphical interface installation. Either way, you now have OpenSSH functionality.

Start the SSH server

Next, open a PowerShell window with administrator privileges and enter the following command to view the OpenSSH service just installed. The sshd below is the OpenSSH server.

Get-Service *|where Name -Like '*ssh*'

Status Name Display Name
------ ---- -----------
Stopped ssh-agent OpenSSH Authentication Agent
Stopped sshd OpenSSH SSH Server

Simply start the service.

Start-Service sshd

Now you can use the OpenSSH client to connect, just enter the following command in the PowerShell window (no administrator required). Here I need to remind you that if you use a Microsoft account (that is, Microsoft mailbox) to create and log in to a user, the user name will be truncated to the part before the mailbox @ symbol, specifically, the name of your user folder. This is also a rather deceptive thing that Microsoft has done.

ssh yourusername@localhost

You should then see the command prompt change to indicate that you are now in the SSH environment. Although this environment is still your local machine. If you run commands in this environment, you should also find that this is a cmd window, not a powershell terminal window.

Using SFTP instead of FTP

Well, you may have a question here. Although we have successfully got the OpenSSH server running on Windows, what is its use? This is a good question. To be honest, it is really useless, but in comparison, it is a perfect alternative to FTP.

I think everyone uses FTP frequently. I used to like to open an IIS server on Windows and use it to create an FTP server to transfer files. I believe many people will use it this way. However, as an old protocol, the biggest problem with FTP is that it is not encrypted. All traffic is transmitted openly and can be easily intercepted and read. At this time, it is best to use SFTP instead. Although its name is very similar, it actually has nothing to do with FTP because SFTP is based on the SSH protocol just introduced.

So how to use SFTP? In fact, it is very simple. The OpenSSH server we just built has built-in SFTP support, so SFTP has been set up now. The usage is very simple. Open FTP client software such as FileZilla or WinSCP, open the drop-down list of protocols, and you can see the SFTP option. Just click this option with the mouse and we can get a secure, encrypted and efficient transmission protocol!

In addition, if you are a Linux user, do not install FTP servers such as vsftpd on Linux. It is also unsafe and unnecessary. Simply use your SSH login Linux username and password, find any FTP client software (basically supports SFTP protocol), and log in.

This is the end of this article about how to easily build a Windows SSH server in a few steps. For more information about building a Windows SSH server, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • CentOS 7.6 Telnet service construction process (Openssh upgrade battle first task backup transport line construction)
  • SSH-struts2 01 environment setup for beginners (graphic tutorial)
  • Thoughts on building SSH and solutions to several problems encountered

<<:  MySQL triggers: creating and using triggers

>>:  The ultimate solution for writing bash scripts with nodejs

Recommend

In-depth analysis of Vue's responsive principle and bidirectional data

Understanding object.defineProperty to achieve re...

Specific method to delete mysql service

MySQL prompts the following error I went to "...

Mount the disk in a directory under Ubuntu 18.04

Introduction This article records how to mount a ...

Introduction to HTML_PowerNode Java Academy

What is HTML? HTML is a language used to describe...

HTML 5 Preview

<br />Original: http://www.alistapart.com/ar...

The solution of html2canvas that pictures cannot be captured normally

question First, let me talk about the problem I e...

Detailed explanation of MySQL combined query

Using UNION Most SQL queries consist of a single ...

CSS mimics remote control buttons

Note: This demo is tested in the mini program env...

How to reduce the root directory of XFS partition format in Linux

Table of contents Preface System environment Curr...

JavaScript to implement the back to top button

This article shares the specific code for JavaScr...

WeChat applet realizes the nine-square grid effect

This article shares the specific code for the WeC...

A brief discussion on the use of GROUP BY and HAVING in SQL statements

Before introducing the GROUP BY and HAVING clause...