Posts Tagged ‘prompt’

How to Install ssh client / server on Windows 10, Windows Server 2019 and Windows Server 2022 using PowerShell commands

Wednesday, March 2nd, 2022

How-to-install-OpenSSH-Client-and-Server-on-Windows-10-Windows-Server-2022-Windows-2019-via-command-line-Powershell

Historically to have a running ssh client on Windows it was required to install CygWin or MobaXterm as told in my previous articles Some Standard software programs to install on Windows to make your Desktop feel  more Linux / Unix Desktop and Must have software on Freshly installed Windows OS.
Interesting things have been developed on the Windows scene since then and as of year 2022 on Windows 10 (build 1809 and later) and on Windows 2019, Windows Server 2022, the task to have a running ssh client to use from cmd.exe (command line) became trivial and does not need to have a CygWin Collection of GNU and Open Source tools installed but this is easily done via Windows embedded Apps & Features GUI tool:

To install it from there on 3 easy steps:

 

  1. Via  Settings, select Apps > Apps & Features, then select Optional Features.
  2. Find OpenSSH Client, then click Install
  3. Find OpenSSH Server, then click Install


For Windows domain administrators of a small IT company that requires its employees for some automated script to run stuff for example to tunnel encrypted traffic from Workers PC towards a server port for example to secure the 110 POP Email clients to communicate with the remote Office server in encrypted form or lets say because ssh client is required to be on multiple domain belonging PCs used as Windows Desktops by a bunch of developers in the company it also possible to use PowerShell script to install the client on the multiple Windows machines.

Install OpenSSH using PowerShell
 

To install OpenSSH using PowerShell, run PowerShell as an Administrator. To make sure that OpenSSH is available, run the following cmdlet in PowerShell

Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'


This should return the following output if neither are already installed:

 

Name  : OpenSSH.Client~~~~0.0.1.0
State : NotPresent

Name  : OpenSSH.Server~~~~0.0.1.0
State : NotPresent


Then, install the server or client components as needed:

Copy in PS cmd window

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

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


Both of these should return the following output:
 

Path          :
Online        : True
RestartNeeded : False


If you want to also allow remote access via OpenSSH sshd daemon, this is also easily possible without installing especially an openssh-server Windows variant !

Start and configure OpenSSH Server

To start and configure OpenSSH Server for initial use, open PowerShell as an administrator, then run the following commands to start the sshd service:

# Start the sshd service
Start-Service sshd

# OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'

# Confirm the Firewall rule is configured. It should be created automatically by setup. Run the following to verify
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
    Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it…"
    New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
} else {
    Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
}


Connect to OpenSSH Server
 

Once installed, you can connect to OpenSSH Server from a Windows 10 or Windows Server 2019 device with the OpenSSH client installed using PowerShell or Command Line tool as Administrator and use the ssh client like you would use it on any *NIX host.

C:\Users\User> ssh username@servername


The authenticity of host 'servername (10.10.10.1)' can't be established.
ECDSA key fingerprint is SHA256:(<a large string>).
Are you sure you want to continue connecting (yes/no)?
Selecting yes adds that server to the list of known SSH hosts on your Windows client.

You are prompted for the password at this point. As a security precaution, your password will not be displayed as you type.

Once connected, you will see the Windows command shell prompt:

Domain\username@SERVERNAME C:\Users\username>

 

Running System Restore from command prompt on Windows 7 / Fixing broken Windows 7 laptops

Tuesday, November 20th, 2012

doing system restore on windows 7 from command prompt / windows7 systemrestore logo
On Windows, mostly anyone who has a little idea about computing should know of existence of the famous System Restore.

I'm currently fixing a messed up m$ Windows 7 Acer Aspire 7750, laptop whose Desktop icons has disappeared and it seems it is full of Viruses and Spyware.
ACER notebooks does not have the nice feature of IBM / Lenovo notebooks which has a separate Hidden Partition with Windows 7 Install on it, and besides this the Windows 7 with notebook is licensed to the notebook. So simply downloading any cracked version of Win 7 is not an option.

After consulting with a friend I've figured out the only option I have to fix the "barely working" Windows 7 PC is to use Windows System Restore

windows system restore screenshot choose hard drive / Confirm system restore
 
Usually the traditional way to run System menu is by Navigating to menus:

Start | Programs | Accessories | System Tools | Restore

However as the notebook, I'm fixing is in Dutch as well as it is missing Accessories? Start-up menu, I thought of alternative and did a quick search on how it is possible to run System Restore from command line.

So here is how:

From Windows Command Prompt run command:

%systemroot%\system32\rstrui.exe

Also for me on this Windows 7 Home with Service Pack1, system restore is possible to run by typing in cmd.exe:

rstrui.exe

System Restore choose restore point

Following, few pop-up menus appears which allows choice of the date of last system restore.

I just choose the one made auto few days earlier and proceeded with the System Restore. There is a warning appearing before the system restore warning to make backups before proceeding a step further. Then few clicks a Restart the PC Worked 🙂 It is as quick and easy.

Well of course, though Restoration to a previous working state of the Windows worked like a charm. Still the restored version, was having the usual bunch of Spyware / Malware. So I had to clean up also the Spyware with MalwareBytes and Little Registry Cleaner to solveissues within registry caused by malware.