{"id":185,"date":"2018-09-23T15:32:21","date_gmt":"2018-09-23T13:32:21","guid":{"rendered":"http:\/\/fred151.net\/site\/?p=185"},"modified":"2021-03-30T11:43:24","modified_gmt":"2021-03-30T09:43:24","slug":"how-to-install-openssh-on-windows-7-10","status":"publish","type":"post","link":"https:\/\/fred151.net\/site\/2018\/09\/23\/how-to-install-openssh-on-windows-7-10\/","title":{"rendered":"How to install OpenSSH on Windows 7 \/ 10"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Use SSH on Windows, how running\/launching graphical programs on remote computer in the same user session logon on Windows OS.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Requirements:<\/strong><br>&#8211; OpenSSH (you can download the binaries from the official repository on github <a href=\"https:\/\/github.com\/PowerShell\/Win32-OpenSSH\/releases\">https:\/\/github.com\/PowerShell\/Win32-OpenSSH\/releases<\/a>)<br>&#8211; PsTools (official useful tools from Microsoft<a href=\"https:\/\/docs.microsoft.com\/en-us\/sysinternals\/downloads\/pstools\"> https:\/\/docs.microsoft.com\/en-us\/sysinternals\/downloads\/pstools<\/a>)<br>&#8211; PowerShell<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Install Pstools (by microsoft)<\/h1>\n\n\n\n<ol class=\"wp-block-list\"><li>Download the tools<\/li><li>Copy the content of the folder PSTools under \u201cC:\\Windows\\System32\\\u201d.<\/li><li>Open the cmd as administrator and run C:\\Windows\\System32\\psexec.exe, accept the eula license.<\/li><\/ol>\n\n\n\n<h1 class=\"wp-block-heading\">Install SSH Server on Windows 7 \/ 10<\/h1>\n\n\n\n<ol class=\"wp-block-list\"><li>Download the latest OpenSSH for Windows binaries (package OpenSSH-Win64.zip or OpenSSH-Win32.zip)<\/li><li>As the Administrator, extract the package to %PROGRAMFILES%\\OpenSSH<br>note: the folder must be named \u201cOpenSSH\u201d<\/li><li>Open PowerShell as the Administrator (right click on PowerShell icon, \u201crun as administrator\u201d), change directory to \u201cC:\\Program Files\\OpenSSH\u201d install sshd and ssh-agent services with the command <pre>&gt; cd \u201c%PROGRAMFILES%\\OpenSSH\u201d &gt; powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1<\/pre> <\/li><li>&nbsp;Allow incoming connections to SSH server in Windows Firewall:<br>&#8211; Either run the following PowerShell command (Windows 8 and 2012 or newer only), as the Administrator: &nbsp; <pre>New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22<\/pre> <p>&#8211; or go to Control Panel &gt; System and Security &gt; Windows Firewall&gt; Advanced Settings &gt; Inbound Rules and add a new rule for port 22.<span style=\"font-size: 1rem;\"> <\/span><\/p><\/li><li>Start the service and\/or configure automatic start:<br>\u25e6 Go to Control Panel &gt; System and Security &gt; Administrative Tools and open Services. Locate sshd service.<br>\u25e6 If you want the server to start automatically when your machine is started: Go to Action &gt; Properties. In the Properties dialog, change Startup type to Automatic and confirm.<br>\u25e6 Start the sshd service by clicking the Start the service.<\/li><li> Create the ~.\/.ssh folder under C:\\Users\\&lt;user&gt;\\.ssh <\/li><li> Create the file \u201cauthorized_keys\u201d under ~.\/.ssh <\/li><li> Run the scrips to fix\/check correct permission a PowerShell with administrator privilege. <pre>&gt; powershell.exe -ExecutionPolicy Bypass -File FixHostFilePermissions.ps1 &gt; powershell.exe -ExecutionPolicy Bypass -File FixUserFilePermissions.ps1<\/pre> <\/li><li>Personalize your SSH server settings editing the configuration file %PROGRAMDATA%\\ssh\\sshd_config.<\/li><\/ol>\n\n\n\n<h1 class=\"wp-block-heading\">Install SSH Client on Windows 7 \/ 10<\/h1>\n\n\n\n<ol class=\"wp-block-list\"><li>Do the step from 1 to 2 from the above paragraph \u201cInstall SSH Server on Windows 7 \/ 10\u201d<\/li><\/ol>\n\n\n\n<h1 class=\"wp-block-heading\">Enable public keys without using password on <strong>client<\/strong><\/h1>\n\n\n\n<ol class=\"wp-block-list\"><li>Open cmd.exe as Administrator and run ssh-keygen.exe and press enter to all message for default configuration<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt; cd \u201c%PROGRAMFILES%\\OpenSSH\u201d\n&gt; .\/ssh-keygen.exe<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">Enable public keys without using password on <strong>Server<\/strong><\/h1>\n\n\n\n<ol class=\"wp-block-list\"><li>Copy the private and public key on the ~.ssh folder of the user that you want use on the server.Run ssh-add.exe to add you private and public key to the ssh-agent.<br>Note: ensure that ssh-agent is running. <\/li><\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\"> &gt; .\/ssh-add.exe <\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">Run graphical programs on remote computer with Windows using psexec.exe<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Connect to the remote machine with ssh and run notepad.exe on the remote computer in the same user sessions opened.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt; cd \u201c%PROGRAMFILES%\\OpenSSH\u201d\n&gt; ssh.exe [remote_local_user]@[remote_ip] -i \u201cC:\\Users\\\\.ssh\\id_rsa\u201d\nuser@remote_ip&gt; psexec.exe \\\\127.0.0.1 -d -i -s notepad.exe<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use SSH on Windows, how running\/launching graphical programs on remote computer in the same user session logon on Windows OS. Requirements:&#8211; OpenSSH (you can download the binaries from the official repository on github https:\/\/github.com\/PowerShell\/Win32-OpenSSH\/releases)&#8211; PsTools (official useful tools from Microsoft https:\/\/docs.microsoft.com\/en-us\/sysinternals\/downloads\/pstools)&#8211; PowerShell Install Pstools (by microsoft) Download the tools Copy the content of the folder [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":207,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-185","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sysadmin"],"_links":{"self":[{"href":"https:\/\/fred151.net\/site\/wp-json\/wp\/v2\/posts\/185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fred151.net\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fred151.net\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fred151.net\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fred151.net\/site\/wp-json\/wp\/v2\/comments?post=185"}],"version-history":[{"count":10,"href":"https:\/\/fred151.net\/site\/wp-json\/wp\/v2\/posts\/185\/revisions"}],"predecessor-version":[{"id":457,"href":"https:\/\/fred151.net\/site\/wp-json\/wp\/v2\/posts\/185\/revisions\/457"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fred151.net\/site\/wp-json\/wp\/v2\/media\/207"}],"wp:attachment":[{"href":"https:\/\/fred151.net\/site\/wp-json\/wp\/v2\/media?parent=185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fred151.net\/site\/wp-json\/wp\/v2\/categories?post=185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fred151.net\/site\/wp-json\/wp\/v2\/tags?post=185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}