{"id":174,"date":"2020-11-27T12:27:44","date_gmt":"2020-11-27T11:27:44","guid":{"rendered":"http:\/\/www.underealm.com\/tech\/?p=174"},"modified":"2020-11-27T12:27:44","modified_gmt":"2020-11-27T11:27:44","slug":"vscode-ssh-and-you","status":"publish","type":"post","link":"https:\/\/www.underealm.com\/tech\/2020\/11\/vscode-ssh-and-you\/","title":{"rendered":"VSCode, SSH, and you"},"content":{"rendered":"\n<p>In this very short post we&#8217;ll take a look at how to properly set up your environment to allow you working with your local IDE to a remote server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Identity files<\/h2>\n\n\n\n<p>Since you&#8217;re logging through an identity file \u2014 because you&#8217;re not logging in with a password now, are you? \u2014 we need to bind a specified host to a user and identity file, also known as OpenSSH private key. To do so we modify or create <code>~\/.ssh\/config<\/code> or <code>%UserProfile%\\.ssh\\config<\/code> on Windows. The file structure is pretty simple:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Host &lt;ip\/hostname>\n\tUser &lt;username>\n\tIdentityFile &lt;PEM file path><\/code><\/pre>\n\n\n\n<p>With that information saved, we can simply <code>ssh &lt;ip\/hostname><\/code> to remote in, without specifying anything.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Identity passphrase<\/h2>\n\n\n\n<p>The next problem in our automation process is to store the passphrase for the session, to avoid manual prompts each time we start a remote instance of VSCode. In order to do this we need to ensure that <code>ssh-agent<\/code> is running properly. On Windows it&#8217;s enough to make sure that the &#8220;OpenSSH Authentication Agent&#8221; service is running, while on Linux it depends on the distro. Generally, we can make sure that it&#8217;s running by issuing <code>ps x | grep ssh-[a]gent<\/code>, and running <code>ssh-agent<\/code> once if it&#8217;s not.<\/p>\n\n\n\n<p>Now we can simply <code>ssh-add &lt;PEM file path><\/code>, insert our passphrase, and ssh with reckless abandon.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Visual Studio Code<\/h2>\n\n\n\n<p>The majority of the work has now been done, we can simply install the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode-remote.vscode-remote-extensionpack\">Remote Development<\/a> extension, and to remote in we select &#8220;Remote SSH: Connect to Host\u2026&#8221; from the command palette, or press on the little green area in the bottom left part of the status bar.<\/p>\n\n\n\n<p>From there we just &#8220;Open folder&#8221; and navigate the remote server directory structure, open where we want and code at leisure.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this very short post we&#8217;ll take a look at how to properly set up your environment to allow you working with your local IDE to a remote server. Identity files Since you&#8217;re logging through an identity file \u2014 because you&#8217;re not logging in with a password now, are you? \u2014 we need to bind [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[33,85,28,100,29,98,97,73],"class_list":["post-174","post","type-post","status-publish","format-standard","hentry","category-antifud","tag-antifud-2","tag-linux","tag-openssh","tag-remote-development","tag-ssh","tag-visual-studio","tag-visual-studio-code","tag-windows"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/posts\/174"}],"collection":[{"href":"https:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/comments?post=174"}],"version-history":[{"count":1,"href":"https:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/posts\/174\/revisions"}],"predecessor-version":[{"id":175,"href":"https:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/posts\/174\/revisions\/175"}],"wp:attachment":[{"href":"https:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/media?parent=174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/categories?post=174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/tags?post=174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}