PowerShell is a powerful command-line shell and scripting language that is commonly used in the IT industry. By default, Windows uses the Command Prompt (cmd) as the default shell, but you can also configure PowerShell to be the default shell. In this article, we will guide you through the process of configuring PowerShell for OpenSSH instead of cmd.
Step 1: Install OpenSSH
The first step is to install OpenSSH on your Windows machine. OpenSSH is an open-source implementation of the SSH protocol that allows secure remote login and file transfer. You can download the latest version of OpenSSH for Windows from the official website.
Step 2: Set PowerShell as the default shell
Once OpenSSH is installed, you need to set PowerShell as the default shell for OpenSSH. Follow these steps:
- Open a PowerShell window as an administrator.
- Run the following command to open the SSH server configuration file in a text editor:
notepad C:\ProgramData\ssh\sshd_config - In the text editor, find the line that starts with
#Subsystem sftpand remove the#at the beginning of the line to uncomment it. - Replace the line with the following line:
Subsystem powershell C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -sshs -NoLogo -NoProfile - Save the changes and close the text editor.
Step 3: Restart the SSH server
After making the changes to the SSH server configuration file, you need to restart the SSH server for the changes to take effect. Follow these steps:
- Open the Services window by pressing
Win + Rand typingservices.msc. - Scroll down and find the "OpenSSH SSH Server" service.
- Right-click on the service and select "Restart" from the context menu.
Step 4: Test the configuration
Now that you have configured PowerShell for OpenSSH, you can test if everything is working correctly. Follow these steps:
- Open a new PowerShell window.
- Run the following command to connect to your local SSH server:
ssh localhost - Enter your Windows username and password when prompted.
- If everything is configured correctly, you should now be connected to your local SSH server using PowerShell.
Congratulations! You have successfully configured PowerShell for OpenSSH instead of cmd. You can now use the full power of PowerShell in your SSH sessions.
References
| Number | Source |
|---|---|
| 1 | OpenSSH on Windows - Installation and First Use |
| 2 | Starting Windows PowerShell |