{"id":236,"date":"2013-08-31T01:45:58","date_gmt":"2013-08-30T23:45:58","guid":{"rendered":"http:\/\/www.dereckson.be\/blog\/?p=236"},"modified":"2013-09-01T01:26:32","modified_gmt":"2013-08-31T23:26:32","slug":"use-ssh-agent-on-windows","status":"publish","type":"post","link":"https:\/\/www.dereckson.be\/blog\/2013\/08\/31\/use-ssh-agent-on-windows\/","title":{"rendered":"Use ssh-agent on Windows"},"content":{"rendered":"<p>ssh-agent is a part of OpenSSH to setup an agent. An agent is a piece of software to store the private keys in memory and ease agent forwarding. This is a requirement to painless SSH operations.<\/p>\n<p>Mark A. Hershberger <a title=\"Using ssh-agent with ssh\" href=\"http:\/\/mah.everybody.org\/docs\/ssh\">explains here a popular way to configure ssh-agent on UNIX system<\/a>.<\/p>\n<p>When you launch the agent a first time (for example at boot time), it will store the PID and socket file into environment variables (SSH_AGENT_PID and SSH_AUTH_SOCK). The goal of the game is to set these environment variables on every session you&#8217;ll launch.<\/p>\n<p>On Windows systems, well\u2026 whether you use only your cygwin terminal, whether you script something usable for Windows console or PowerShell sessions. But then, you won&#8217;t be able to access your agent from most GUI applications using SSH (some like ActiveState Komodo will allow you to tweak environment variables).<\/p>\n<p><strong>When PuTTY utilities aren&#8217;t enough \u2014 The ControlMaster story.<br \/>\n<\/strong><\/p>\n<p>At the time of the writing, the popular way is the Windows GUI SSH world is to use the PuTTY products Pageant and plink. That&#8217;s fine and works very well, except one caveat: you don&#8217;t have the possibility to use <a title=\"SSH ControlMaster: The Good, The Bad, The Ugly\" href=\"http:\/\/www.anchor.com.au\/blog\/2010\/02\/ssh-controlmaster-the-good-the-bad-the-ugly\/\">ControlMaster<\/a>.<\/p>\n<p>ControlMaster is an OpenSSH feature to multiplex SSH connections. If you have an open master SSH connection to the server X, you can get a new connection to X without the need to authenticate again. This speeds a lot operations like save a file, launch a version control or debug command (my main scenario use: when I&#8217;m writing OS-dependant PHP code I like to test it on Windows and FreeBSD). On my workstation, ssh server hostname with ControlMaster is instantaneous, plink server hostname requires 2 seconds.<\/p>\n<p><strong>A patch: ssh-agent -x<br \/>\n<\/strong><\/p>\n<p>So, to let my fellow Cygwin OpenSSH users the capability to use also scp and ssh with an universally-available agent, I prepared <a href=\"http:\/\/dereckson.devio.us\/patches\/OpenSSH-20130830-CygwinSSHAgentSetx.patch\">this patch for ssh-agent.c to add a new -x parameter<\/a>.<\/p>\n<p>This patch applies against the <a title=\"OpenSSH Portable Release for Linux\/Solaris\/etc\" href=\"http:\/\/www.openssh.com\/portable.html\">portable OpenSSH<\/a> version.<\/p>\n<p>To compile OpenSSH on Cygwin you need autoconf and zlib.<\/p>\n<p>Once recompiled with this patch, to launch once for all your agent:<br \/>\n<code>ssh-agent -x<br \/>\nssh-add [path to key if not in .ssh\/]<\/code><\/p>\n<p>And enjoy it until your next shutdown or logout.<\/p>\n<p><strong>Alternatives<\/strong><\/p>\n<ul>\n<li>An alternative <a href=\"http:\/\/cygwin.com\/ml\/cygwin-apps\/2011-11\/threads.html#00006\">but non consensual<\/a> solution is <a title=\"win-ssh-agent\" href=\"https:\/\/github.com\/ganaware\/win-ssh-agent\">win-ssh-agent<\/a>, a GUI wrapper written by TAGA Nayuta.<\/li>\n<li>To launch GUI software from a shell with the environment variables to propagate such environment, like explained supra in this blog post <a title=\" openssh in Windows 7, run ssh-add once for all cmd instances\" href=\"http:\/\/superuser.com\/questions\/479834\/openssh-in-windows-7-run-ssh-add-once-for-all-cmd-instances\">or here<\/a>.<\/li>\n<li>If you use both PuTTY and OpenSSH, you&#8217;ll find interesting <a title=\"ssh-pageant\" href=\"http:\/\/cuviper.github.io\/ssh-pageant\/\">ssh-pageant<\/a> from <a title=\"CUViper\" href=\"http:\/\/blog.cuviper.com\">Josh Stone<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>ssh-agent is a part of OpenSSH to setup an agent. An agent is a piece of software to store the private keys in memory and ease agent forwarding. This is a requirement to painless SSH operations. Mark A. Hershberger explains here a popular way to configure ssh-agent on UNIX system. When you launch the agent [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[98,96,97],"class_list":["post-236","post","type-post","status-publish","format-standard","hentry","category-dev","tag-cygwin","tag-openssh","tag-ssh"],"_links":{"self":[{"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/posts\/236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/comments?post=236"}],"version-history":[{"count":6,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/posts\/236\/revisions"}],"predecessor-version":[{"id":242,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/posts\/236\/revisions\/242"}],"wp:attachment":[{"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/media?parent=236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/categories?post=236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/tags?post=236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}