### Manual Installation of Win32-OpenSSH Source: https://context7.com/powershell/win32-openssh/llms.txt Provides a step-by-step guide for manually installing Win32-OpenSSH from GitHub releases. This involves downloading the latest release, extracting it, installing the SSHD service, configuring the firewall, and starting the service. It also includes the uninstallation process. ```powershell # 1. Download latest release (programmatically get download links) [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $url = 'https://github.com/PowerShell/Win32-OpenSSH/releases/latest/' $request = [System.Net.WebRequest]::Create($url) $request.AllowAutoRedirect=$false $response=$request.GetResponse() $([String]$response.GetResponseHeader("Location")).Replace('tag','download') + '/OpenSSH-Win64.zip' # 2. Extract to Program Files Expand-Archive -Path OpenSSH-Win64.zip -DestinationPath "C:\Program Files\OpenSSH" # 3. Install SSHD service (elevated PowerShell) powershell.exe -ExecutionPolicy Bypass -File "C:\Program Files\OpenSSH\install-sshd.ps1" # 4. Configure firewall (Windows 2012+) New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 # Alternative firewall command for Windows 2008 R2 and earlier netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP localport=22 # 5. Start SSHD service net start sshd # 6. Set SSHD to auto-start Set-Service sshd -StartupType Automatic # Uninstall powershell.exe -ExecutionPolicy Bypass -File "C:\Program Files\OpenSSH\uninstall-sshd.ps1" ``` -------------------------------- ### SFTP Client Usage Examples Source: https://github.com/powershell/win32-openssh/wiki/sftp.exe-examples This section provides command-line examples for using the sftp.exe client. It covers logging into local and remote hosts using passwords or public key authentication, navigating remote and local directories, downloading files, uploading files, and exiting the SFTP session. ```bash sftp test1@localhost sftp -i .ssh/id_rsa test1@remotehost pwd lpwd cd /tests get file1.txt put file2.txt exit ``` -------------------------------- ### Install Win32-OpenSSH using MSI (Command Prompt) Source: https://github.com/powershell/win32-openssh/wiki/Install-Win32-OpenSSH-Using-MSI These commands are used to install Win32-OpenSSH via its MSI package. You can choose to install both the client and server, only the client, or only the server. The MSI is typically run from a command prompt. ```bash msiexec /i msiexec /i ADDLOCAL=Client msiexec /i ADDLOCAL=Server ``` -------------------------------- ### Build OpenSSH for Windows using Visual Studio Source: https://github.com/powershell/win32-openssh/wiki/Building-OpenSSH-for-Windows-(using-LibreSSL-crypto) Provides steps for building OpenSSH for Windows using Visual Studio. This includes installing Visual Studio with specific components, configuring the project, and building the binaries. It also details how to verify installations of Visual Studio, Windows SDK, and Build Tools. ```powershell # Ensure Visual Studio with 'Desktop Development with C++' workload and necessary SDK/Build Tools are installed. # Open the solution file: contrib\win32\openssh\Win32-OpenSSH.sln # Set platform toolset to 'no upgrade' and Windows SDK to '10.0.22621.0' if prompted. # Select the desired configuration (e.g., Release) and architecture (e.g., x64) from the toolbar. # Build the solution. # Note: After the first build or when updating libcrypto, copy libcrypto.dll from contrib\win32\openssh\libressl\bin\desktop\{Architecture}\ to .\bin\{Architecture}\{Configuration} ``` -------------------------------- ### Start and Configure SSHD Service Source: https://github.com/powershell/win32-openssh/wiki/Install-Win32-OpenSSH Commands to start the SSHD service and optionally configure it to start automatically on system boot. Starting the service generates host keys if they do not exist. ```powershell net start sshd Set-Service sshd -StartupType Automatic ``` -------------------------------- ### Deploy OpenSSH for Windows Source: https://github.com/powershell/win32-openssh/wiki/Building-OpenSSH-for-Windows-(using-LibreSSL-crypto) Generates a zipped payload containing OpenSSH binaries and symbols for deployment. Further installation instructions can be found on the Win32-OpenSSH wiki. ```powershell Start-OpenSSHPackage -Configuration -NativeHostArch # Follow further installation instructions at https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH. ``` -------------------------------- ### Clone and Bootstrap Vcpkg for Dependency Management Source: https://github.com/powershell/win32-openssh/wiki/Building-OpenSSH-for-Windows-(using-LibreSSL-crypto) Clones the Vcpkg repository and bootstraps it, which is required for managing dependencies for OpenSSH builds starting September 2025. It also integrates Vcpkg with Visual Studio. ```bash git clone https://github.com/Microsoft/Vcpkg ./bootstrap-vcpkg.bat ./vcpkg.exe integrate install ``` -------------------------------- ### Install OpenSSH using MSI Source: https://context7.com/powershell/win32-openssh/llms.txt Installs, updates, or uninstalls OpenSSH components using the Microsoft Installer (MSI) package. This method allows for granular control over which components (Client, Server) are installed or removed. It also includes steps to update the system PATH and verify the service installation. ```powershell # Install both SSH Client and Server (default) msiexec /i openssh.msi # Install only the SSH Client msiexec /i openssh.msi ADDLOCAL=Client # Install only the SSH Server msiexec /i openssh.msi ADDLOCAL=Server # Uninstall SSH Client msiexec /i openssh.msi REMOVE=Client # Uninstall SSH Server msiexec /i openssh.msi REMOVE=Server # Complete uninstall msiexec /x openssh.msi # Update SYSTEM PATH (required for SCP and SFTP) [Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path",[System.EnvironmentVariableTarget]::Machine) + ';' + ${Env:ProgramFiles} + '\OpenSSH', [System.EnvironmentVariableTarget]::Machine) # Verify installation Get-Service -Name ssh* ``` -------------------------------- ### Install OpenSSH using WinGet Source: https://context7.com/powershell/win32-openssh/llms.txt Installs or uninstalls OpenSSH Preview releases using the Windows Package Manager (WinGet). This is the simplest method for obtaining the latest preview versions. ```powershell # Search for OpenSSH winget search "openssh preview" # Install OpenSSH (client and server) winget install "openssh preview" # Uninstall OpenSSH winget uninstall "openssh preview" ``` -------------------------------- ### Build OpenSSL with Visual Studio 2015 (Perl) Source: https://github.com/powershell/win32-openssh/wiki/OpenSSH-64-bit-Build-and-Installation-Instructions This snippet demonstrates how to build OpenSSL for both debug and release configurations using Perl scripts and nmake. It requires Strawberry Perl and Visual Studio 2015. The commands configure OpenSSL with specific build options and installation prefixes, followed by the compilation and installation steps. ```shell cd D:\programming\OpenSSL\openssl-1.0.2f perl Configure debug-VC-WIN64A --prefix=d:\programming\OpenSSL\OpenSSLInstallx64_vs2015-debug ms\do_win64a nmake -f ms\nt.mak install perl Configure VC-WIN64A --prefix=d:\programming\OpenSSL\OpenSSLInstallx64_vs2015 ms\do_win64a nmake -f ms\nt.mak install ``` -------------------------------- ### Install Win32-OpenSSH using PowerShell Script Source: https://github.com/powershell/win32-openssh/wiki/Install-Win32-OpenSSH Steps to manually install Win32-OpenSSH by downloading the latest build, extracting it, and running the `install-sshd.ps1` script. Requires elevated PowerShell privileges and manual firewall configuration. ```powershell powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1 ``` -------------------------------- ### Download OpenSSH Portable Source Code Source: https://github.com/powershell/win32-openssh/wiki/Building-OpenSSH-for-Windows-(using-LibreSSL-crypto) Clones the OpenSSH portable repository and checks out the latest stable branch. This is the initial step to obtain the source code for building. ```bash git clone https://github.com/PowerShell/openssh-portable git checkout latestw_all ``` -------------------------------- ### Manage Win32-OpenSSH with WinGet Source: https://github.com/powershell/win32-openssh/wiki/Install-Win32-OpenSSH Commands to search, install, and uninstall Win32-OpenSSH preview releases using the Windows Package Manager (WinGet). This method simplifies the installation and removal process for users with WinGet installed. ```powershell winget search "openssh preview" winget install "openssh preview" winget uninstall "openssh preview" ``` -------------------------------- ### Batch Convert DOS to UNIX EOL using dos2unix utility Source: https://github.com/powershell/win32-openssh/wiki/Dos2Unix---Text-file-format-converters This method involves downloading and installing the dos2unix utility. Once installed and added to the system path, it can be used from the command shell to convert files. The examples show how to convert all files, all '.h' files, or all '.c' files recursively within a directory. ```batch for /R %G in (*.*) do dos2unix "%G" ``` ```batch for /R %G in (*.h) do dos2unix "%G" ``` ```batch for /R %G in (*.c) do dos2unix "%G" ``` -------------------------------- ### Deploy Public Key for Non-Admin Users (PowerShell) Source: https://github.com/powershell/win32-openssh/wiki/Setup-public-key-based-authentication-for-windows Copies the generated public key to the user's authorized_keys file in their .ssh directory. If the .ssh directory does not exist, it needs to be manually created. ```powershell cp $env:USERPROFILE\.ssh\authorized_keys ``` -------------------------------- ### Run Remote PowerShell Command via SSH Source: https://github.com/powershell/win32-openssh/wiki/Run-commands-for-various-shells Executes a 'hello' command on a remote machine using PowerShell as the default shell over SSH. This example demonstrates the client-side command to initiate the remote execution. ```powershell c:\>ssh.exe localhost echo '"hello"' ``` ```powershell c:\>ssh.exe winbox echo `"hello`" ``` ```powershell c:\>ssh.exe localhost "echo `"hello`"" ``` -------------------------------- ### Install ssh-lsa DLL Source: https://github.com/powershell/win32-openssh/wiki/OpenSSH-32-bit-Build-and-Installation-Instructions Installs the compiled ssh-lsa.dll on the system where the sshd server is running. This involves copying the DLL to the System32 directory and updating the Windows Registry to include it in the authentication packages. A system reboot is required after these changes. ```Batch REM Copy the DLL to the system directory copy ssh-lsa.dll %WINDIR%/System32 REM Add 'ssh-lsa.dll' to the Authentication Packages registry key (requires regedit) REM HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Lsa/Authentication Packages ``` -------------------------------- ### Server-Side SSH Key Setup for Win32-OpenSSH Source: https://github.com/powershell/win32-openssh/wiki/ssh.exe-examples Explains how to set up the server-side for SSH key authentication with Win32-OpenSSH. This involves appending the client's public key to the `authorized_keys` file and verifying file permissions. ```shell icacls %systemdrive%\Users\\.ssh\authorized_keys ``` -------------------------------- ### Connect via SSH with Key-Based Authentication (CLI) Source: https://github.com/powershell/win32-openssh/wiki/Setup-public-key-based-authentication-for-windows Attempts to connect to the SSH server using the generated private key. The command syntax differs slightly for domain users versus local users. If the private key is in the default location, the -i flag can be omitted. ```bash ssh user@domain@ip -i (Domain users) ssh user@ip -i (local users) ``` -------------------------------- ### Build OpenSSH for Windows using Build Script Source: https://github.com/powershell/win32-openssh/wiki/Building-OpenSSH-for-Windows-(using-LibreSSL-crypto) Builds OpenSSH for Windows using a PowerShell helper script. This method requires importing the script and then calling the build function with specified configuration and architecture. ```powershell cd repository-root ipmo .\contrib\win32\openssh\OpenSSHBuildHelper.psm1 -Force Start-OpenSSHBuild -Configuration -NativeHostArch ``` -------------------------------- ### Uninstall Win32-OpenSSH using MSI (Command Prompt) Source: https://github.com/powershell/win32-openssh/wiki/Install-Win32-OpenSSH-Using-MSI These commands are used to uninstall Win32-OpenSSH or specific components (Client/Server) using its MSI package. The MSI is typically run from a command prompt. ```bash msiexec /x msiexec /i REMOVE=Client msiexec /i REMOVE=Server ``` -------------------------------- ### Install Chocolatey and Win32-OpenSSH (No Server) Source: https://github.com/powershell/win32-openssh/wiki/[Deprecated]-Win32-OpenSSH-Automated-Install-and-Upgrade-using-Chocolatey A one-liner script to simultaneously install Chocolatey package manager and the Win32-OpenSSH client tools without the SSHD server. It sets the execution policy and downloads/executes an installation script from a GitHub repository. This requires an elevated PowerShell prompt. ```powershell [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {[bool]1};set-executionpolicy RemoteSigned -Force -EA 'SilentlyContinue';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/DarwinJS/ChocoPackages/master/win32-openssh/InstallChoco_and_win32-openssh.ps1')) ``` -------------------------------- ### Install Chocolatey, Win32-OpenSSH, and SSH Server Source: https://github.com/powershell/win32-openssh/wiki/[Deprecated]-Win32-OpenSSH-Automated-Install-and-Upgrade-using-Chocolatey A one-liner script to install Chocolatey package manager, Win32-OpenSSH client tools, and the SSHD server simultaneously. It configures the execution policy and downloads/executes an installation script from GitHub. This command must be run in an elevated PowerShell prompt. ```powershell [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {[bool]1};set-executionpolicy RemoteSigned -Force -EA 'SilentlyContinue';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/DarwinJS/ChocoPackages/master/win32-openssh/InstallChoco_and_win32-openssh_with_server.ps1')) ``` -------------------------------- ### Get Server Operating System (PowerShell) Source: https://github.com/powershell/win32-openssh/blob/L1-Prod/ISSUE_TEMPLATE.md Retrieves the product name of the Windows Server operating system from the registry. This command uses PowerShell to query the 'CurrentVersion' registry key. ```powershell ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion\" -Name ProductName).ProductName) ``` -------------------------------- ### Configure OpenSSL Paths in OpenSSH Targets Source: https://github.com/powershell/win32-openssh/wiki/OpenSSH-64-bit-Build-and-Installation-Instructions This XML snippet shows how to update the 'paths.targets' file within the Win32-OpenSSH project to point to the directories where OpenSSL was built and installed. It specifies paths for different configurations, including debug/release and x86/x64 targets. ```xml D:\programming\OpenSSL\OpenSSLInstallx64_vs2015-debug\ D:\programming\OpenSSL\OpenSSLInstallx86_vs2015\ D:\programming\OpenSSL\OpenSSLInstallx86_vs2015-debug\ D:\programming\OpenSSL\OpenSSLInstallx64_vs2015\ D:\programming\OpenSSL\OpenSSLInstallx64_vs2015-debug\ ``` -------------------------------- ### Install SSH Client Tools with Chocolatey Source: https://github.com/powershell/win32-openssh/wiki/[Deprecated]-Win32-OpenSSH-Automated-Install-and-Upgrade-using-Chocolatey Installs the SSH client tools without the SSHD server using the Chocolatey package manager. This command ensures the installation proceeds without interactive confirmation. ```powershell choco install win32-openssh -confirm ``` -------------------------------- ### Run Remote cmd.exe Command via SSH Source: https://github.com/powershell/win32-openssh/wiki/Run-commands-for-various-shells Executes a 'hello' command on a remote machine using cmd.exe as the default shell over SSH. This example illustrates the specific syntax for invoking commands through cmd.exe on the remote host. ```cmd c:\>ssh.exe winbox echo "hello" ``` ```cmd c:\>ssh.exe winbox "echo ""hello""" ``` -------------------------------- ### Install SSH Client Tools and Server with Chocolatey Source: https://github.com/powershell/win32-openssh/wiki/[Deprecated]-Win32-OpenSSH-Automated-Install-and-Upgrade-using-Chocolatey Installs both SSH client tools and the SSHD server using the Chocolatey package manager. It utilizes specific parameters to enable the SSH server and key-based authentication features. The command includes confirmation for execution. ```powershell choco install win32-openssh -params '"/SSHServerFeature /KeyBasedAuthenticationFeature"' -confirm ``` -------------------------------- ### Kerberos Authentication Setup and Usage with Win32-OpenSSH Source: https://github.com/powershell/win32-openssh/wiki/ssh.exe-examples Covers the server-side setup for Kerberos authentication in Win32-OpenSSH by configuring `sshd_config` and restarting the `sshd` service. It also shows the client-side usage for domain-joined Windows users. ```shell net stop sshd net start sshd ssh -K host ``` -------------------------------- ### SSH Client Key Authentication Source: https://context7.com/powershell/win32-openssh/llms.txt Explains how to generate and use SSH key pairs for passwordless authentication. This includes generating keys, starting and adding keys to the ssh-agent for single sign-on, and connecting explicitly with a key file or implicitly via the agent. ```powershell # 1. Generate RSA key pair on client ssh-keygen.exe -t rsa -f $env:USERPROFILE\.ssh\id_rsa # Enter passphrase when prompted (recommended) or press Enter to skip # 2. Start ssh-agent service for key management net start ssh-agent # 3. Add private key to ssh-agent (enables single sign-on) ssh-add $env:USERPROFILE\.ssh\id_rsa # 4. Connect using key file explicitly ssh -i $env:USERPROFILE\.ssh\id_rsa user@host # 5. Connect using key from ssh-agent (no -i flag needed) ssh user@host # Domain user with key authentication ssh -i .\id_rsa -l user@domain host ``` -------------------------------- ### Run Remote Bash Command via SSH Source: https://github.com/powershell/win32-openssh/wiki/Run-commands-for-various-shells Executes a 'hello' command on a remote machine using Bash as the default shell over SSH. This showcases different quoting and escaping methods for the command executed on the client. ```bash c:\>ssh winbox 'echo "hello"' ``` ```bash c:\>ssh.exe winbox echo \"hello\" ``` ```bash c:\>ssh winbox echo '"hello"' ``` -------------------------------- ### Run ssh in Verbose Mode (PowerShell) Source: https://github.com/powershell/win32-openssh/wiki/Troubleshooting-Steps This snippet demonstrates how to initiate an SSH client connection in verbose mode to capture detailed debugging information. Multiple levels of verbosity can be achieved by adding more 'v' characters. ```powershell ssh.exe -v ... # For more detailed logging: ssh.exe -vv ... ssh.exe -vvv ... ``` -------------------------------- ### Deploy Public Key for Admin Users (PowerShell) Source: https://github.com/powershell/win32-openssh/wiki/Setup-public-key-based-authentication-for-windows Copies the generated public key to the server's administrator authorized keys file and sets the appropriate Access Control Lists (ACLs). This requires an elevated PowerShell window and assumes default sshd_config settings. ```powershell cp "$env:programdata\ssh\administrators_authorized_keys" get-acl "$env:programdata\ssh\ssh_host_rsa_key" | set-acl "$env:programdata\ssh\administrators_authorized_keys" ``` -------------------------------- ### SSH Key Generation and Usage with Win32-OpenSSH Source: https://github.com/powershell/win32-openssh/wiki/ssh.exe-examples Details the process of generating SSH key pairs on the client-side and using them for authentication with Win32-OpenSSH. It includes steps for starting and adding keys to the ssh-agent. ```shell ssh-keygen -t rsa -f id_rsa net start ssh-agent ssh-add id_rsa ssh -i .\id_rsa user@host ssh -i .\id_rsa -l user@domain host ``` -------------------------------- ### Run Remote Cygwin Command via SSH Source: https://github.com/powershell/win32-openssh/wiki/Run-commands-for-various-shells Executes a 'hello' command on a remote machine using Cygwin as the default shell over SSH. Similar to Bash, this demonstrates various ways to quote and escape the command string for remote execution. ```cygwin c:\>ssh winbox 'echo "hello"' ``` ```cygwin c:\>ssh.exe winbox echo \"hello\" ``` ```cygwin c:\>ssh winbox echo '"hello"' ``` -------------------------------- ### Generate SSH Key Pair (PowerShell) Source: https://github.com/powershell/win32-openssh/wiki/Setup-public-key-based-authentication-for-windows Generates an RSA public and private key pair on the client machine using ssh-keygen.exe. This command is executed from the OpenSSH binary folder. Users can optionally set a passphrase for the private key. ```powershell ssh-keygen.exe -t rsa -f $env:USERPROFILE\.ssh\id_rsa ``` -------------------------------- ### Run SSHD in Interactive Debug Mode Source: https://context7.com/powershell/win32-openssh/llms.txt Starts the SSHD service in debug mode for real-time troubleshooting. This allows for detailed output and can be run with different privilege levels using psexec. Client-side verbose options are also included. ```powershell # Stop sshd service first Stop-Service sshd # Run sshd in debug mode (can only login as current user with key auth) sshd.exe -d # Run as SYSTEM for full functionality psexec -s sshd.exe -d # Increase verbosity sshd.exe -dd sshd.exe -ddd # Client-side verbose mode ssh.exe -v user@host ssh.exe -vv user@host ssh.exe -vvv user@host ``` -------------------------------- ### Configure Authorized Keys for Passwordless Login Source: https://github.com/powershell/win32-openssh/wiki/OpenSSH-32-bit-Build-and-Installation-Instructions Appends a public SSH key to the `.ssh/authorized_keys` file in a user's home directory. This allows passwordless login for that user via SSH. The example uses the `type` command to append the content of `id_rsa.pub`. ```Shell type id_rsa.pub >> .ssh/authorized_keys ``` -------------------------------- ### Configure SFTP Subsystem in sshd_config Source: https://github.com/powershell/win32-openssh/wiki/sftp.exe-examples This snippet shows how to add the sftp-server.exe binary as a subsystem in the sshd_config file. This allows the SSH server to handle SFTP connections. After modifying the configuration, the sshd service must be restarted for the changes to take effect. ```powershell Subsystem sftp sftp-server.exe Restart-Service sshd ``` -------------------------------- ### Generate CA Keys for SSHD Authentication Source: https://github.com/powershell/win32-openssh/wiki/Certificate-Authentication Generates the Certificate Authority (CA) keys required for signing user certificates. This process is similar to generating any other SSH key pair and produces both a private and public key file. ```powershell ssh-keygen -t rsa -f ca_userkeys ``` -------------------------------- ### Configure SSH Server for Certificate-Based Authentication (PowerShell) Source: https://context7.com/powershell/win32-openssh/llms.txt This PowerShell script guides through setting up certificate-based authentication for the SSH server. It includes generating CA keys, configuring `sshd_config` to trust the CA, signing user keys, and restarting the SSH service. ```powershell # 1. Generate CA keys ssh-keygen -t rsa -f ca_userkeys # 2. Add to sshd_config (use absolute path recommended) # TrustedUserCAKeys C:\ProgramData\ssh\ca_userkeys.pub # 3. Sign user keys (username must match user to authenticate) ssh-keygen.exe -s ca_userkeys -I cert_identity -V -1w:+54w5d -n username id_rsa.pub # Restart sshd after config changes net stop sshd net start sshd ``` -------------------------------- ### Verify Win32-OpenSSH Service Status (PowerShell) Source: https://github.com/powershell/win32-openssh/wiki/Install-Win32-OpenSSH-Using-MSI This PowerShell command checks the status of the SSH service installed by Win32-OpenSSH. It helps verify that the service is running after installation. ```powershell Get-Service -Name ssh* ``` -------------------------------- ### Build Win32-OpenSSH from Source using Visual Studio Source: https://context7.com/powershell/win32-openssh/llms.txt Steps to clone the Win32-OpenSSH repository, set up Vcpkg, open the solution in Visual Studio, configure build settings, and copy necessary DLLs after the initial build. ```powershell # Clone source repository git clone https://github.com/PowerShell/openssh-portable git checkout latestw_all # Clone and setup vcpkg (required as of September 2025) git clone https://github.com/Microsoft/vcpkg .\vcpkg\bootstrap-vcpkg.bat .\vcpkg\vcpkg.exe integrate install # Open solution in Visual Studio # contrib\win32\openssh\Win32-OpenSSH.sln # Set platform toolset: no upgrade # Set Windows SDK: 10.0.22621.0 # Build solution # Copy libcrypto.dll after first build Copy-Item .\contrib\win32\openssh\libressl\bin\desktop\x64\libcrypto.dll .\bin\x64\Debug\ ``` -------------------------------- ### Update SYSTEM PATH for Win32-OpenSSH (PowerShell) Source: https://github.com/powershell/win32-openssh/wiki/Install-Win32-OpenSSH-Using-MSI This PowerShell command appends the Win32-OpenSSH installation directory to the system's PATH environment variable. This is required for SCP and SFTP to function correctly. The command must be run in an elevated PowerShell session. ```powershell [Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path",[System.EnvironmentVariableTarget]::Machine) + ';' + ${Env:ProgramFiles} + '\OpenSSH', [System.EnvironmentVariableTarget]::Machine) ``` -------------------------------- ### Add SSH Private Key to Agent (Bash) Source: https://github.com/powershell/win32-openssh/wiki/Setting-up-a-Git-server-on-Windows-using-Git-for-Windows-and-Win32_OpenSSH Registers the generated user private key with the SSH agent for single sign-on. This allows you to use the key without re-entering your passphrase repeatedly. This is an optional step. ```bash ssh-add.exe c:\test\myprivatekey ``` -------------------------------- ### Generate SSH Key Pair (Bash) Source: https://github.com/powershell/win32-openssh/wiki/Setting-up-a-Git-server-on-Windows-using-Git-for-Windows-and-Win32_OpenSSH Generates an SSH key pair (public and private) using ed25519 encryption. This is an optional step for enabling key-based authentication. The keys are saved to the specified file path. ```bash ssh-keygen.exe -t ed25519 -f c:\test\myprivatekey ``` -------------------------------- ### Configure Git SSH Command (PowerShell) Source: https://github.com/powershell/win32-openssh/wiki/Setting-up-a-Git-server-on-Windows-using-Git-for-Windows-and-Win32_OpenSSH Sets the GIT_SSH_COMMAND environment variable on the client to use Win32-OpenSSH's ssh.exe. This ensures Git uses the specified SSH client for remote operations. This setting is typically temporary for the current session. ```powershell $env:GIT_SSH_COMMAND = '"C:\Program Files\OpenSSH\ssh.exe" -T' ``` -------------------------------- ### Set MinGW32 Toolchain for OpenSSH Build Source: https://github.com/powershell/win32-openssh/wiki/OpenSSH-32-bit-Build-and-Installation-Instructions This script sets up the MinGW32 toolchain by creating symbolic links. It's a prerequisite for compiling 32-bit OpenSSH components. Ensure you have administrative rights before running. ```Shell cd c:/cygwin32/bin c:/win32openssh/Win32-OpenSSH/scripts/set-mingw32.sh ``` -------------------------------- ### Set System Environment Variable for SSHD (PowerShell) Source: https://github.com/powershell/win32-openssh/wiki/Setting-up-a-Git-server-on-Windows-using-Git-for-Windows-and-Win32_OpenSSH Configures the system's PATH environment variable on the server to include the Git binary directory. This allows sshd to recognize Git commands. It requires administrator privileges to modify the machine-level environment variables. ```powershell $gitPath = Join-Path -Path $env:ProgramFiles -ChildPath "git\mingw64\bin" $machinePath = [Environment]::GetEnvironmentVariable('Path', 'MACHINE') [Environment]::SetEnvironmentVariable('Path', "$gitPath;$machinePath", 'Machine') ``` -------------------------------- ### Workaround Git Clone Issue with PowerShell (Bash) Source: https://github.com/powershell/win32-openssh/wiki/Setting-up-a-Git-server-on-Windows-using-Git-for-Windows-and-Win32_OpenSSH Provides a workaround for a known issue where `git clone user@domain@servermachine:C:/test/myrepo.git` fails. It involves setting PowerShell as the default shell or configuring Git to use PowerShell for upload-pack and receive-pack operations. ```bash cd c:\mygitrepros git init mylocalrepo cd mylocalrepo git remote add origin user@domain@servermachine:C:/test/myrepo.git git config --local remote.origin.uploadpack "powershell git-upload-pack" git config --local remote.origin.receivepack "powershell git-receive-pack" git fetch origin ``` -------------------------------- ### Connect to SFTP Server (PowerShell and Bash) Source: https://context7.com/powershell/win32-openssh/llms.txt These snippets show how to connect to an SFTP server using the `sftp` client in both PowerShell and Bash. It includes connecting with username/password and using key-based authentication. ```powershell # Connect to SFTP server sftp test1@localhost # Connect using key authentication sftp -i .ssh/id_rsa test1@remotehost ``` ```bash # SFTP session commands pwd # Show current remote directory lpwd # Show current local directory cd /tests # Change to remote directory c:/tests get file1.txt # Download file from remote to local put file2.txt # Upload file from local to remote exit # Close session ``` -------------------------------- ### Build and Package Win32-OpenSSH using PowerShell Script Source: https://context7.com/powershell/win32-openssh/llms.txt Utilizes the OpenSSHBuildHelper.psm1 module to build and package the Win32-OpenSSH project for release. This simplifies the build process for deployment. ```powershell cd openssh-portable # Import build helper Import-Module .\contrib\win32\openssh\OpenSSHBuildHelper.psm1 -Force # Build Start-OpenSSHBuild -Configuration Release -NativeHostArch x64 # Package for deployment Start-OpenSSHPackage -Configuration Release -NativeHostArch x64 ``` -------------------------------- ### Uninstall Win32-OpenSSH using PowerShell Script Source: https://github.com/powershell/win32-openssh/wiki/Install-Win32-OpenSSH Instructions to uninstall Win32-OpenSSH by navigating to its installation directory and executing the `uninstall-sshd.ps1` script. Requires administrator privileges. ```powershell cd 'C:\Program Files\OpenSSH' powershell.exe -ExecutionPolicy Bypass -File uninstall-sshd.ps1 ``` -------------------------------- ### Build 32-bit OpenSSH Binaries Source: https://github.com/powershell/win32-openssh/wiki/OpenSSH-32-bit-Build-and-Installation-Instructions Builds the 32-bit OpenSSH suite of tools, including ssh.exe, sshd.exe, and others. Requires the previously compiled 32-bit OpenSSL and ZLIB libraries. The generated zlib1.dll must be accessible in the PATH or current directory. ```Shell ./win32_build # To build a specific program (e.g., sftp): make sftp.exe # To test ssh client version: ./ssh -V ``` -------------------------------- ### Compile ZLIB Library for 32-bit OpenSSH Source: https://github.com/powershell/win32-openssh/wiki/OpenSSH-32-bit-Build-and-Installation-Instructions Compiles the ZLIB source code to generate the 32-bit libz.a library and zlib.dll. This is essential for the operation of 32-bit OpenSSH binaries. Download ZLIB sources (e.g., zlib-1.2.8.tar.gz) before running. ```Shell tar -xvf zlib-1.2.8.tar.gz cd zlib-1.2.8 make -f win32/Makefile.gcc ``` -------------------------------- ### SSH Client Kerberos Authentication Source: https://context7.com/powershell/win32-openssh/llms.txt Details how to use Kerberos/GSSAPI for authentication in domain-joined Windows environments. It shows the client command to connect using Kerberos and mentions the server-side configuration required in `sshd_config`. ```powershell # Connect using Kerberos (domain user on domain-joined client) # Note: Use hostname, not IP address ssh -K hostname # Server-side: Enable GSSAPI in sshd_config # GSSAPIAuthentication yes ``` -------------------------------- ### Get Win32-OpenSSH Version (PowerShell) Source: https://github.com/powershell/win32-openssh/blob/L1-Prod/ISSUE_TEMPLATE.md Retrieves the file version of the Win32-OpenSSH daemon (sshd). This command requires PowerShell and access to the sshd executable's file information. ```powershell ((Get-Item (Get-Command sshd).Source).VersionInfo.FileVersion) ```