How to Create a Native SSH Server on Your Windows 10 System « Null Byte :: WonderHowTo

With the addition of theOpenSSHclient and server in theWindows 10 Fall Creators Update, you no longer have to rely on third-party programs to open an SSH server and connect to a Windows machine. While still a beta feature, this represents a long-overdue update fulfilling apromisemade back in 2015.TheOpenSSH clientallows you toSSHinto remote servers directly from the Windows command line. The server lets remote clients connect to your Windows 10 system, where they will be able to receive a command prompt for your system remotely. If you are familiar with OpenSSH from Linux, then you'll be right at home with the Windows 10 version.OpenSSH for Windows is definitely in beta form and should only be used in a safe, testing environment such as your home network. This shouldn't be used in production or opened to the internet. That being said, as time goes on, this implementation of OpenSSH should grow more secure and useful.To follow this guide, you'll need a Windows 10 computer that has been fully updated. Before starting, make sure to check for and install any updates Windows may have or these steps may not work properly. To check for updates, you can go to the Start button, and then go to "Settings" –> "Update & security" –> "Windows Update," then click on "Check for updates."Step 1: Enable Developer ModeTo begin, we need to ensure that the Windows system is set to "Developer mode," otherwise it will be impossible to download these beta features. Navigate to the search bar on the bottom left of your screen. Search for "developers settings" and it should appear underBest matchin the results. Select it to open the settings.Now you should see theUse developer featuresmenu. The "Windows Store apps" setting will be selected by default, so click on "Developer mode" to enable it. It should take a few moments to install the 6 MB file, and just like that, you're a Windows developer!Step 2: Install the OpenSSH ServerOnce developer mode is enabled, we're ready to install OpenSSH, and there are a few ways to do this, depending on your preferences. We'll cover both PowerShell and DISM.Method 1: Using PowerShellThe entire install process can be done inPowerShell, which is more convenient if you are installing OpenSSH on more than one computer. This could easily be turned into aUSB Rubber Duckyscript to make the process of setting up an SSH server lighting-fast. Some hackers might even start using this as a way to create an SSH backdoor on Windows systems.Don't Miss:How to Load & Use Keystroke Injection Payloads on the USB Rubber DuckyFirst, run PowerShell as the administrator by pressingWindows+Xon your keyboard and clicking on "Windows PowerShell (Admin)." Then, check to ensure that the OpenSSH features are available for installation by running the following command.Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'The shell should return "NotPresent" which means that the server isn't yet downloaded. As you can see,I have the OpenSSH Client installed, and the server is available for installation.Assuming OpenSSH is available, you can install the server with the following command. If it is not available, make sure your system is updated and that developer mode is enabled, as those are the two most common problems which can cause this.Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0Note that the prompt may say a restart isn't needed, but it's my experience that a restart is, in fact, required. When the process is complete, you should see something like the screen below.Method 2: Using DISMIf you'd prefer to use the command-line over PowerShell,Deployment Image Servicing and Management(DISM) is a command-line tool that we can also use to install the OpenSSH server.To begin installing OpenSSH with DISM, open a command prompt as an administrator. This can be done by searching for "CMD" in the search bar at the bottom left-hand corner of the screen. Right-click on "Command Prompt" and then select "Run as Administrator."Check that the OpenSSH features are available with the following command.dism /Online /Get-Capabilities | findstr OpenSSHIf you get the following, then you are ready to install the server.Install the server with this command:dism /Online /Add-Capability /CapabilityName:OpenSSH.Server~~~~0.0.1.0You will need to reboot the computer after installation.Step 3: Generate Host KeysNow that we have the server installed, we need to generate host keys so the SSH server will be able to authenticate clients while it's in use. To do this, we will open PowerShell as the administrator by pressingWindows+Xand clicking on "Windows PowerShell (Admin)." Start the ssh-agent with the following command.Start-Service ssh-agentOnce the ssh-agent is running, we can move to the OpenSSH folder and begin generating a key. Usecdto change folders as seen in the first command below, and then create the key with the second.cd C:\Windows\System32\OpenSSH.\ssh-keygen -ANow, we can add the key to our SSH server with the following command..\ssh-add sshhosted25519_keyThis is the key that will be used from now on for our SSH connections.Don't Miss:How to Generate Private Encryption Keys with the Diffie-Hellman Key ExchangeStep 4: Install the OpenSSHUtils Helper ModuleYou could attempt to use the SSH server now, but if you do, you'll run into a whole slew of errors. This is because the server is still in beta, and is very finicky.To help resolve these issues, Microsoft has created the OpenSSHUtils helper module, which will appropriately add your host keys and set permissions to the Access Control List (ACL). To install OpenSSHUtils, we will run the command below.Install-Module -Force OpenSSHUtilsIt may also ask to install the package managerNuGet. If you don't already have it, typeyto install it.Once that's done, we are ready to run the helper module, which should clean up those errors we saw before. Run the following command to install it.Repair-SshdHostKeyPermission -FilePath C:\Windows\System32\OpenSSH\sshhosted25519_keyYou will revive a number of prompts; useyas your response to all of the prompts to set the file permissions correctly. As you can see below, you have to say yes quite a few times.Step 5: Open a Port in the FirewallNow, everything should be ready to go on the SSH server side of things. We just need to open a port in the firewall so we can establish an SSH connection with a client outside of the current Windows system. Your requirements may vary based on your environment, but in general, the following firewall rule should work for most Windows users. Input the following command to open a local port 22 named SSH.New-NetFirewallRule -Protocol TCP -LocalPort 22 -Direction Inbound -Action Allow -DisplayName SSHStep 6: Start Your New SSH ServerThat's it. You're ready to start using your SSH server! One thing to note, only the built-inED25519 authentication key typeis currently supported. There are plans to addLibreSSLin the future, which will enable additional authentication key types, but as of yet, that has not been done. So for now, use an ED25519 key to connect to the server.The SSH server doesn't start up automatically, so we have to start it manually each time we wish to use the server by typingStart-Service sshdinto our PowerShell window. You can check to see that it's running withGet-Service sshd.You should always remember to stop the service when not in use withStop-Service sshdto maintain the security of your system.To connect to your new SSH server, use your favorite SSH client such asPuTTYor thenew OpenSSH client. In general, you can use the following format to connect.ssh username@host -p portWhen you connect to your new server, you'll find that you get a full command prompt, which can run all command line tools, even PowerShell! With the addition of the OpenSSH Client to Windows 10 as well, you now have an extra layer of flexibility where you can directly connect two Windows systems over SSH.Don't Miss:How to Use SSH Local Port Forwarding to Pivot into Restricted NetworksWindows Is Easier Than Ever to Administer RemotelyThe new built-in SSH server is a welcome addition to Windows 10. It represents Microsoft taking steps to listen to developers and system administrators to meet their needs. This new feature allows you to manage a Windows machine much more easily, and as Windows continues to improve and implement OpenSSH as a full feature, I believe more and more people will come to use it due to its ease of use and convenience. The days of the third-party SSH servers dominating the Windows field are numbered.Thanks for reading! If you have any questions, you can ask me here or on Twitter@The_Hoid.Don't Miss:How to Enable the New Native SSH Client on Windows 10Follow Null Byte onTwitter,Flipboard, andYouTubeFollow WonderHowTo onFacebook,Twitter,Pinterest, andFlipboardWant to start making money as a white hat hacker?Jump-start your hacking career with our2020 Premium Ethical Hacking Certification Training Bundlefrom the newNull Byte Shopand get over 60 hours of training from cybersecurity professionals.Buy Now (90% off) >Other worthwhile deals to check out:97% off The Ultimate 2021 White Hat Hacker Certification Bundle99% off The 2021 All-in-One Data Scientist Mega Bundle98% off The 2021 Premium Learn To Code Certification Bundle62% off MindMaster Mind Mapping Software: Perpetual LicenseCover image and screenshots by Hoid/Null ByteRelatedHow To:Enable the New Native SSH Client on Windows 10Hacking Windows 10:How to Use SSH Tunnels to Forward Requests & Hack Remote RoutersHow To:Use the Chrome Browser Secure Shell App to SSH into Remote DevicesHacking Windows 10:How to Turn Compromised Windows PCs into Web ProxiesHow To:Run Your Favorite Graphical X Applications Over SSHSSH the World:Mac, Linux, Windows, iDevices and Android.Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 15 (Creating a Secure Tunnel to MySQL)How To:Set Up an SSH Server with Tor to Hide It from Shodan & HackersSPLOIT:How to Make an SSH Brute-Forcer in PythonHow To:Configure a Reverse SSH Shell (Raspberry Pi Hacking Box)How To:Locate & Exploit Devices Vulnerable to the Libssh Security FlawHow To:Detect Misconfigurations in 'Anonymous' Dark Web Sites with OnionScanHacking Windows 10:How to Hack uTorrent Clients & Backdoor the Operating SystemHow To:Use the Cowrie SSH Honeypot to Catch Attackers on Your NetworkHow To:Create an SSH tunnel for your Mac Mini serverHow To:Discover & Attack Services on Web Apps or Networks with SpartaHow To:Use SSH Local Port Forwarding to Pivot into Restricted NetworksHacking Windows 10:How to Capture & Exfiltrate Screenshots RemotelyHow To:Upload a Shell to a Web Server and Get Root (RFI): Part 1How To:Build a Beginner Hacking Kit with the Raspberry Pi 3 Model B+Rasberry Pi:Connecting on ComputerAndroid for Hackers:How to Backdoor Windows 10 Using an Android Phone & USB Rubber DuckyHacking Windows 10:How to Remotely Record & Listen to the Microphone of a Hacked ComputerHack Like a Pro:How to Crash Your Roommate's Windows 7 PC with a LinkHow To:SSH and FTP into a serverHow To:Remotely Control Computers Over VNC Securely with SSHHow To:Push and Pull Remote Files Securely Over SSH with PipesHow To:Create a Free SSH Account on Shellmix to Use as a Webhost & MoreHow To:Create an SSH Tunnel Server and Client in LinuxHow To:Safely Log In to Your SSH Account Without a PasswordHow To:Stream Media to a PS3 or Xbox 360 from Mac & Linux ComputersNews:What does Pro Tools HD Native mean for you?How To:Mask Your IP Address and Remain Anonymous with OpenVPN for LinuxHacking Reconnaissance:Finding Vulnerabilities in Your Target Using NmapHow To:Run an FTP Server from Home with LinuxHow To:Create Your Own Native American Girl Halloween Costume