{"id":1416,"date":"2016-02-18T12:28:46","date_gmt":"2016-02-18T17:28:46","guid":{"rendered":"http:\/\/codinggorilla.domemtech.com\/?p=1416"},"modified":"2016-04-02T09:53:19","modified_gmt":"2016-04-02T13:53:19","slug":"getting-ssh-on-friggin-windows-working","status":"publish","type":"post","link":"http:\/\/165.227.223.229\/index.php\/2016\/02\/18\/getting-ssh-on-friggin-windows-working\/","title":{"rendered":"Getting SSH\/Git Clients on Friggin&#8217; Windows Working"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Secure_Shell\" target=\"_blank\">Secure\u00c2\u00a0Shell (SSH)<\/a> is a network protocol used ubiquitously, e.g., github.com, bitbucket.com, etc. If you use <a href=\"https:\/\/en.wikipedia.org\/wiki\/Git_(software)\" target=\"_blank\">Git<\/a> or <a href=\"https:\/\/en.wikipedia.org\/wiki\/Mercurial\" target=\"_blank\">Hg<\/a>, it&#8217;s nice to set up SSH because you can avoid having to re-enter your user id and password every time you clone the repository. (Or, if you are really desperate, encode the user id and password in the URI for the repository.) While there may be <a href=\"https:\/\/www.google.com\/search?q=How%20to%20establish%20passwordless%20login%20with%20ssh\" target=\"_blank\">a lot of information<\/a>\u00c2\u00a0(e.g.,\u00c2\u00a0<a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-set-up-ssh-keys--2\" target=\"_blank\">here<\/a>\u00c2\u00a0and <a href=\"https:\/\/help.ubuntu.com\/community\/SSH\/OpenSSH\/Keys\" target=\"_blank\">here<\/a>) on how to set this up, it&#8217;s almost always Linux-centric, using ssh, ssh-add, ssh-keygen commands. <a href=\"https:\/\/cygwin.com\/\" target=\"_blank\">Cygwin<\/a> has an\u00c2\u00a0implementation\u00c2\u00a0which looks just like the Linux toolset, but\u00c2\u00a0<a href=\"http:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/download.html\" target=\"_blank\">Putty<\/a> is the SSH system most use\u00c2\u00a0on Windows. Unfortunately, Git checks the environmental variables, and special cases the connection (see the kludges in git_connect in <a href=\"https:\/\/github.com\/git\/git\/blob\/master\/connect.c\" target=\"_blank\">connect.c<\/a>). So, if you try Git from Cygwin, it may not use the same SSH system in some other environment, like <a href=\"https:\/\/www.sourcetreeapp.com\/\" target=\"_blank\">SourceTree<\/a>. (If you look for &#8220;git.exe&#8221; in your PC, it&#8217;s sprinkled throughout.) If you didn&#8217;t know that and use Windows, God help you because you can spend days trying to figure out why things don&#8217;t work while sifting through the mountains of useless information! This protocol outlines the steps involved to set up SSH for both Cygwin and Putty.<\/p>\n<p>Prerequisites:<\/p>\n<ul>\n<li>Cygwin installed<\/li>\n<li>Account on Github.com<\/li>\n<li>Git installed (https:\/\/git-scm.com\/downloads)<\/li>\n<li>Git GUI (https:\/\/git-scm.com\/downloads\/guis). I recommend SourceTree (https:\/\/www.sourcetreeapp.com\/).<\/li>\n<\/ul>\n<p>Method:<\/p>\n<ol>\n<ol>\n<li>Open a Cygwin Terminal, and execute the following commands in order presented&#8230;<\/li>\n<li><code>which ssh<\/code>\n<ol>\n<li>Note: Verify that you have SSH installed for Cygwin. If not, go to http:\/\/cygwin.com, download the installer, run it and install SSH.<\/li>\n<\/ol>\n<\/li>\n<li>I HIGHLY recommend you use Pageant. Place in your ~\/.bashrc file\u00c2\u00a0<code>eval $(\/usr\/local\/bin\/ssh-pageant -ra $TEMP\/.ssh-pageant).<\/code>, See\u00c2\u00a0<a href=\"https:\/\/github.com\/cuviper\/ssh-pageant\" target=\"_blank\">https:\/\/github.com\/cuviper\/ssh-pageant<\/a>.\n<ol>\n<li>If you don&#8217;t plan on using Pageant,\u00c2\u00a0eval `ssh-agent -s`;\u00c2\u00a0<code>ssh-add -L<\/code><\/li>\n<li>Note: look at the output to see if there are any keys added. There may or may not, it doesn&#8217;t matter because you&#8217;re going to generate and add a new key here.<\/li>\n<\/ol>\n<\/li>\n<li><code>cd ~\/.ssh<\/code>\n<ol>\n<li>Note: If you don&#8217;t have the directory, execute <code>cd<\/code>, then <code>mkdir .ssh<\/code> to create one, then <code>cd .ssh<\/code>.<\/li>\n<\/ol>\n<\/li>\n<li>\u00c2\u00a0ssh-keygen -t rsa<\/li>\n<li>On the prompts, you can just return for each thing prompted for.<\/li>\n<li><code>ls<\/code>\n<ol>\n<li>Note: Verify you have\u00c2\u00a0id_rsa, id_rsa.pub (or the file name you entered above) generated.<\/li>\n<\/ol>\n<\/li>\n<li><code>cat id_rsa.pub # (or the file you entered above)<\/code>\n<ol>\n<li>Verify the key is not empty.<\/li>\n<\/ol>\n<\/li>\n<li><code>ssh-add<\/code>\n<ol>\n<li>Note: You should see output from ssh-add indicating it added the keys in the ~\/.ssh directory. If not, it may have been already added.<\/li>\n<\/ol>\n<\/li>\n<li><code>ssh-add -L<\/code>\n<ol>\n<li>Note: Verify you have the key you just created added.<\/li>\n<\/ol>\n<\/li>\n<li>In an editor like Notepad, open the .PUB file and copy the text into the clipboard.<\/li>\n<li>In a browser, log into github.com (or create an account).<\/li>\n<li>In Github.com, to the the upper-right corner, and click on the icon for the user, and then settings in the pulldown.\n<ol>\n<li>Add a key.\u00c2\u00a0See\u00c2\u00a0https:\/\/help.github.com\/articles\/adding-a-new-ssh-key-to-your-github-account\/ for more info.<\/li>\n<\/ol>\n<\/li>\n<li>Back in the Cygwin Terminal started in step 1 &#8230;<\/li>\n<li><code>ssh -v git@github.com<\/code>\n<ul>\n<li>When it prompts for &#8220;do you want to continue?&#8221;, enter yes.<\/li>\n<li>The output should look like this:<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/ol>\n<p>&nbsp;<\/p>\n<pre>$ ssh -v git@github.com\r\nOpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015\r\ndebug1: Connecting to github.com [192.30.252.129] port 22.\r\ndebug1: Connection established.\r\ndebug1: identity file \/home\/Ken\/.ssh\/id_rsa type 1\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file \/home\/Ken\/.ssh\/id_rsa-cert type -1\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file \/home\/Ken\/.ssh\/id_dsa type -1\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file \/home\/Ken\/.ssh\/id_dsa-cert type -1\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file \/home\/Ken\/.ssh\/id_ecdsa type -1\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file \/home\/Ken\/.ssh\/id_ecdsa-cert type -1\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file \/home\/Ken\/.ssh\/id_ed25519 type -1\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file \/home\/Ken\/.ssh\/id_ed25519-cert type -1\r\ndebug1: Enabling compatibility mode for protocol 2.0\r\ndebug1: Local version string SSH-2.0-OpenSSH_7.1\r\ndebug1: Remote protocol version 2.0, remote software version libssh-0.7.0\r\ndebug1: no match: libssh-0.7.0\r\ndebug1: Authenticating to github.com:22 as 'git'\r\ndebug1: SSH2_MSG_KEXINIT sent\r\ndebug1: SSH2_MSG_KEXINIT received\r\ndebug1: kex: server-&gt;client chacha20-poly1305@openssh.com &lt;implicit&gt; none\r\ndebug1: kex: client-&gt;server chacha20-poly1305@openssh.com &lt;implicit&gt; none\r\ndebug1: expecting SSH2_MSG_KEX_ECDH_REPLY\r\ndebug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8\r\nThe authenticity of host 'github.com (192.30.252.129)' can't be established.\r\nRSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.\r\nAre you sure you want to continue connecting (yes\/no)? yes\r\nWarning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts.\r\ndebug1: SSH2_MSG_NEWKEYS sent\r\ndebug1: expecting SSH2_MSG_NEWKEYS\r\ndebug1: SSH2_MSG_NEWKEYS received\r\ndebug1: Roaming not allowed by server\r\ndebug1: SSH2_MSG_SERVICE_REQUEST sent\r\ndebug1: SSH2_MSG_SERVICE_ACCEPT received\r\ndebug1: Authentications that can continue: publickey\r\ndebug1: Next authentication method: publickey\r\ndebug1: Offering RSA public key: \/home\/Ken\/.ssh\/id_rsa\r\ndebug1: Server accepts key: pkalg ssh-rsa blen 279\r\ndebug1: Authentication succeeded (publickey).\r\nAuthenticated to github.com ([192.30.252.129]:22).\r\ndebug1: channel 0: new [client-session]\r\ndebug1: Entering interactive session.\r\nPTY allocation request failed on channel 0\r\ndebug1: client_input_channel_req: channel 0 rtype exit-status reply 0\r\nHi kaby76! You've successfully authenticated, but GitHub does not provide shell access.\r\ndebug1: channel 0: free: client-session, nchannels 1\r\nConnection to github.com closed.\r\nTransferred: sent 3388, received 1796 bytes, in 0.1 seconds\r\nBytes per second: sent 42231.9, received 22387.4\r\ndebug1: Exit status 1\r\n<\/pre>\n<ol>\n<ol>\n<ol start=\"16\">\n<li>git clone git@github.com:heroku\/ruby-rails-sample.git\n<ol>\n<li>Note: This verifies that command-line Git works. If it doesn&#8217;t then you should probably use ssh-pageant because git is not using the right agent.<\/li>\n<\/ol>\n<\/li>\n<li>Note: If you use SourceTree (or other Git clients), verify they work too. This is because they use a damn separate authentication tool: <a href=\"https:\/\/en.wikipedia.org\/wiki\/PuTTY#Components\" target=\"_blank\">pageant.exe<\/a>. You can tell if you see in the lower-right corner the Pageant server icon.<\/li>\n<li>Find the Pageant server, and open it<\/li>\n<li><img loading=\"lazy\" class=\"aligncenter size-large wp-image-1418\" src=\"http:\/\/codinggorilla.domemtech.com\/wordpress\/wp-content\/uploads\/2016\/02\/2016-02-18-4-1024x581.png\" alt=\"2016-02-18 (4)\" width=\"676\" height=\"384\" \/><\/li>\n<li>In SourceTree, go to menu item &#8220;Tools | Create or Import SSH Keys&#8221;.<\/li>\n<li>In the dialog box, click on &#8220;Load&#8221; button, and find the file id_rsa (or the file name you entered above). You will have to type it in explicitly, or remove the stupid filter for the open file dialog box. Save the key, both public and private (generates a PPK file that&#8217;s compatible with Pageant).<\/li>\n<li>In Pageant, &#8220;Add Key&#8221;, using the .PPK generated above by SourceTree utility.<\/li>\n<li>Execute plink.exe in the Atlassian\/SourceTree installation directory from Cygwin Terminal or Cmd.<\/li>\n<li>plink git@github.com<\/li>\n<li>In SourceTree, In SourceTree, clone the above Ruby sample. If it hangs, use plink.exe from the Cygwin Terminal.<\/li>\n<\/ol>\n<\/ol>\n<\/ol>\n<pre>$ plink git@github.com\r\nHi kaby76! You've successfully authenticated, but GitHub does not provide shell access.\r\nUsing username \"git\".\r\nServer refused to allocate pty\r\n<\/pre>\n<p>Additional Information<\/p>\n<ol>\n<ul>\n<li>Putty &#8211; <a href=\"https:\/\/en.wikipedia.org\/wiki\/PuTTY\" target=\"_blank\">Wikipedia<\/a><\/li>\n<li>SSH client set up &#8211; <a href=\"http:\/\/docs.oracle.com\/cd\/E24628_01\/install.121\/e22624\/preinstall_req_cygwin_ssh.htm#EMBSC150\" target=\"_blank\">Oracle<\/a><\/li>\n<\/ul>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Secure\u00c2\u00a0Shell (SSH) is a network protocol used ubiquitously, e.g., github.com, bitbucket.com, etc. If you use Git or Hg, it&#8217;s nice to set up SSH because you can avoid having to re-enter your user id and password every time you clone the repository. (Or, if you are really desperate, encode the user id and password &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/165.227.223.229\/index.php\/2016\/02\/18\/getting-ssh-on-friggin-windows-working\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Getting SSH\/Git Clients on Friggin&#8217; Windows Working&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts\/1416"}],"collection":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/comments?post=1416"}],"version-history":[{"count":0,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts\/1416\/revisions"}],"wp:attachment":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/media?parent=1416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/categories?post=1416"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/tags?post=1416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}