{"id":23262,"date":"2023-07-11T10:22:05","date_gmt":"2023-07-11T08:22:05","guid":{"rendered":"https:\/\/info.gwdg.de\/news\/?p=23262"},"modified":"2023-07-17T13:08:23","modified_gmt":"2023-07-17T11:08:23","slug":"configuring-vscode-to-access-gwdgs-hpc-cluster","status":"publish","type":"post","link":"https:\/\/info.gwdg.de\/news\/configuring-vscode-to-access-gwdgs-hpc-cluster\/","title":{"rendered":"Configuring VSCode to access GWDG&#8217;s HPC Cluster"},"content":{"rendered":"<p><a href=\"https:\/\/code.visualstudio.com\/\" target=\"_blank\" rel=\"nofollow noreferrer noopener\" class=\"external\">VSCode<\/a> is a popular lightweight IDE developed by Microsoft that supports many programming languages and scripts. There are many features and capabilities that can be added to VSCode by installing extensions from the <a href=\"https:\/\/marketplace.visualstudio.com\/VSCode\" target=\"_blank\" rel=\"nofollow noreferrer noopener\" class=\"external\">marketplace<\/a>, including the ability to develop on a remote machine and manage files intuitively using its GUI.<\/p>\n<figure id=\"attachment_23271\" aria-describedby=\"caption-attachment-23271\" style=\"width: 1912px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/info.gwdg.de\/news\/wp-content\/uploads\/2023\/07\/vscode-screenshot.png\" class=\"external\" rel=\"nofollow\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-23271 size-full\" src=\"https:\/\/info.gwdg.de\/news\/wp-content\/uploads\/2023\/07\/vscode-screenshot.png\" alt=\"\" width=\"1922\" height=\"985\" \/><\/a><figcaption id=\"caption-attachment-23271\" class=\"wp-caption-text\">Screenshot of VSCode. Source: Ali Doost Hosseini<\/figcaption><\/figure>\n<p>This document <a href=\"https:\/\/gitlab-ce.gwdg.de\/hpc-team-public\/science-domains-blog\/-\/blob\/main\/20230711_hpc-on-vscode.md\" class=\"external\" rel=\"nofollow\">provides instructions<\/a> for setting up VSCode to connect to GWDG&#8217;s HPC cluster.<\/p>\n<p>Note: To acccess the cluster, you will need an <a href=\"https:\/\/docs.gwdg.de\/doku.php?id=en:services:application_services:high_performance_computing:account_activation\" target=\"_blank\" rel=\"nofollow noreferrer noopener\" class=\"external\">activated, non-student account<\/a><\/p>\n<h2>Extensions<\/h2>\n<p dir=\"auto\" data-sourcepos=\"11:1-11:61\">Install the following extensions from the VSCode marketplace:<\/p>\n<ul>\n<li data-sourcepos=\"13:3-13:110\"><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode-remote.remote-ssh\" target=\"_blank\" rel=\"nofollow noreferrer noopener\" class=\"external\">Remote &#8211; SSH by Microsoft<\/a><\/li>\n<li data-sourcepos=\"15:3-15:131\"><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode-remote.remote-ssh-edit\" target=\"_blank\" rel=\"nofollow noreferrer noopener\" class=\"external\">Remote &#8211; SSH: Editing Configuration Files<\/a><\/li>\n<li data-sourcepos=\"17:3-17:98\"><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode.remote-explorer\" target=\"_blank\" rel=\"nofollow noreferrer noopener\" class=\"external\">Remote Explorer<\/a><\/li>\n<\/ul>\n<h2>SSH Configuration<\/h2>\n<h3>Generate an SSH key<\/h3>\n<p dir=\"auto\" data-sourcepos=\"24:1-24:345\">First, you will need an SSH key. On Linux, macOS and the latest Windows versions SSH is already built in. A key can be generated with the command <code>ssh-keygen -t rsa -b 2048 -f &lt;yourkey&gt;<\/code>. As soon as you enter the command you will be asked to secure the key with a passphrase. Please do not use keys without a passphrase to log in to our systems.<\/p>\n<div class=\"gl-relative markdown-code-block js-markdown-code\">\n<pre class=\"code highlight js-syntax-highlight language-plaintext white\" lang=\"plaintext\" data-canonical-lang=\"\" data-sourcepos=\"26:1-47:3\"><code><\/code><\/pre>\n<pre class=\"code highlight\" lang=\"plaintext\"><span id=\"LC1\" class=\"line\" lang=\"plaintext\">PS C:\\Users\\win10-virtual&gt; ssh-keygen -t rsa -b 2048 -f .ssh\/id-rsa<\/span>\r\n<span id=\"LC2\" class=\"line\" lang=\"plaintext\">Generating public\/private rsa key pair.<\/span>\r\n<span id=\"LC3\" class=\"line\" lang=\"plaintext\">Enter passphrase (empty for no passphrase):<\/span>\r\n<span id=\"LC4\" class=\"line\" lang=\"plaintext\">Enter same passphrase again:<\/span>\r\n<span id=\"LC5\" class=\"line\" lang=\"plaintext\">Your identification has been saved in .ssh\/id-rsa.<\/span>\r\n<span id=\"LC6\" class=\"line\" lang=\"plaintext\">Your public key has been saved in .ssh\/id-rsa.pub.<\/span>\r\n<span id=\"LC7\" class=\"line\" lang=\"plaintext\">The key fingerprint is:<\/span>\r\n<span id=\"LC8\" class=\"line\" lang=\"plaintext\">SHA256:JIFSfI6\/QBdnUaVsjKdHIfCqw1yjZyk96KDp07MlvbM win10-virtual@DESKTOP-N8DT68R<\/span>\r\n<span id=\"LC9\" class=\"line\" lang=\"plaintext\">The key's randomart image is:<\/span>\r\n<span id=\"LC10\" class=\"line\" lang=\"plaintext\">+---[RSA 2048]----+<\/span>\r\n<span id=\"LC11\" class=\"line\" lang=\"plaintext\">|   o..o.ooo..    |<\/span>\r\n<span id=\"LC12\" class=\"line\" lang=\"plaintext\">|  . o ooo= o     |<\/span>\r\n<span id=\"LC13\" class=\"line\" lang=\"plaintext\">|   . +.++ B      |<\/span>\r\n<span id=\"LC14\" class=\"line\" lang=\"plaintext\">|    o o+ =       |<\/span>\r\n<span id=\"LC15\" class=\"line\" lang=\"plaintext\">|   . o+ S .      |<\/span>\r\n<span id=\"LC16\" class=\"line\" lang=\"plaintext\">|   oo*.o .       |<\/span>\r\n<span id=\"LC17\" class=\"line\" lang=\"plaintext\">|  o.O+*.         |<\/span>\r\n<span id=\"LC18\" class=\"line\" lang=\"plaintext\">| + =o*o.         |<\/span>\r\n<span id=\"LC19\" class=\"line\" lang=\"plaintext\">|+...+Eo          |<\/span>\r\n<span id=\"LC20\" class=\"line\" lang=\"plaintext\">+----[SHA256]-----+ <\/span>\r\n<\/pre>\n<pre id=\"code-14\" class=\"code highlight js-syntax-highlight language-plaintext white\" lang=\"plaintext\" data-canonical-lang=\"\" data-sourcepos=\"26:1-47:3\"><code><span id=\"LC20\" class=\"line\" lang=\"plaintext\"><\/span><\/code><\/pre>\n<\/div>\n<p dir=\"auto\" data-sourcepos=\"49:1-49:103\">This creates both the private key file <code>&lt;yourkey&gt;<\/code> and a corresponding public key file <code>&lt;yourkey&gt;.pub<\/code>.<\/p>\n<blockquote dir=\"auto\" data-sourcepos=\"51:1-51:79\">\n<p data-sourcepos=\"51:2-51:79\">Note: Never give out your private key, but always upload only the public key!<\/p>\n<h3 data-sourcepos=\"51:2-51:79\">Upload the SSH Key<\/h3>\n<p dir=\"auto\" data-sourcepos=\"55:1-55:200\">To upload a key, please log into your account on the <a href=\"https:\/\/www.gwdg.de\" target=\"_blank\" rel=\"nofollow noreferrer noopener\" class=\"external\">GWDG Website<\/a>, go to <strong>My Account<\/strong>. Then scroll down to <strong>Other Settings<\/strong> and click <strong>edit<\/strong>. You can now add a public key.<\/p>\n<blockquote dir=\"auto\" data-sourcepos=\"57:1-57:212\">\n<p data-sourcepos=\"57:3-57:212\">Note: If you copy your public key from a text editor or a terminal, please make sure that your editor or your terminal does not insert any linebreaks, because this will make the copy of your public key invalid.<\/p>\n<h2 data-sourcepos=\"57:3-57:212\">SSH Configuration File<\/h2>\n<p dir=\"auto\" data-sourcepos=\"61:1-61:234\">Now you will need to setup an SSH configuration file. In VSCode, press <kbd>Ctrl<\/kbd> + <kbd>Shift<\/kbd> + <kbd>P<\/kbd> and select the entry <code>Remote - SSH: Open SSH Configuration file<\/code>, then select the desired location for this file.<\/p>\n<p dir=\"auto\" data-sourcepos=\"63:1-63:99\">You can add any number of host configurations as you like. Here is an example on a windows machine:<\/p>\n<\/blockquote>\n<\/blockquote>\n<pre class=\"code highlight\" lang=\"plaintext\"><span id=\"LC1\" class=\"line\" lang=\"plaintext\">Host gwdg_mdc<\/span>\r\n<span id=\"LC2\" class=\"line\" lang=\"plaintext\">  HostName login-mdc.hpc.gwdg.de<\/span>\r\n<span id=\"LC3\" class=\"line\" lang=\"plaintext\">  User &lt;username&gt;<\/span>\r\n<span id=\"LC4\" class=\"line\" lang=\"plaintext\">  IdentityFile &lt;path_to_private_key&gt;<\/span>\r\n<span id=\"LC5\" class=\"line\" lang=\"plaintext\"><\/span>\r\n<span id=\"LC6\" class=\"line\" lang=\"plaintext\">Host gwdg_mdc_transfer<\/span>\r\n<span id=\"LC7\" class=\"line\" lang=\"plaintext\">  HostName transfer-mdc.hpc.gwdg.de<\/span>\r\n<span id=\"LC8\" class=\"line\" lang=\"plaintext\">  User &lt;username&gt;<\/span>\r\n<span id=\"LC9\" class=\"line\" lang=\"plaintext\">  IdentityFile &lt;path_to_private_key&gt;<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p>In this example, replace &lt;username&gt; with your GWDG HPC account username, and &lt;path_to_private_key&gt; with the path to the private key.<\/p>\n<h2><a id=\"user-content-connecting-to-the-hpc-cluster\" class=\"anchor\" href=\"#connecting-to-the-hpc-cluster\" aria-hidden=\"true\"><\/a>Connecting to the HPC Cluster<\/h2>\n<p dir=\"auto\" data-sourcepos=\"82:1-82:162\">Now that the SSH configuration file is set up, you may use the <code>Remote Explorer<\/code> on the left sidebar in VSCode to find and select the host you wish to connect to.<\/p>\n<p dir=\"auto\" data-sourcepos=\"84:1-84:217\">Right-click on a host (e.g. <code>gwdg_mdc<\/code> in the previous example) and select <strong>Connect to Host in Current Window<\/strong>. VSCode should then ask for your SSH key&#8217;s passphrase and log you into one of the cluster&#8217;s login nodes.<\/p>\n<h2 dir=\"auto\" data-sourcepos=\"84:1-84:217\"><a id=\"user-content-accessing-a-singularity-container-from-within-vscode\" class=\"anchor\" href=\"#accessing-a-singularity-container-from-within-vscode\" aria-hidden=\"true\"><\/a>Accessing a singularity container from within VSCode<\/h2>\n<p dir=\"auto\" data-sourcepos=\"90:1-90:186\">It is also possible to Remote SSH directly into a singularity container. However, this method uses the login node and therefore should not be used for computationally intensive purposes.<\/p>\n<p dir=\"auto\" data-sourcepos=\"92:1-92:239\">You will need to change some VSCode settings. Press <kbd>Ctrl<\/kbd> + <kbd>Shift<\/kbd> + <kbd>P<\/kbd> and select the entry <code>Preferences: Open User Settings (JSON)<\/code>. In the <code>settings.json<\/code> file, add the following entries, and save the file:<\/p>\n<div class=\"gl-relative markdown-code-block js-markdown-code\">\n<pre id=\"code-16\" class=\"code highlight js-syntax-highlight language-json white\" lang=\"json\" data-sourcepos=\"94:1-97:3\"><code><span id=\"LC1\" class=\"line\" lang=\"json\"><span class=\"nl\">\"remote.SSH.useLocalServer\"<\/span><span class=\"p\">:<\/span> <span class=\"kc\">true<\/span><span class=\"err\">,<\/span><\/span>\r\n<span id=\"LC2\" class=\"line\" lang=\"json\"><span class=\"nl\">\"remote.SSH.enableRemoteCommand\"<\/span><span class=\"p\">:<\/span> <span class=\"kc\">true<\/span><span class=\"err\">,\r\n<\/span><\/span><\/code><\/pre>\n<\/div>\n<p dir=\"auto\" data-sourcepos=\"99:1-99:169\">\n<p dir=\"auto\" data-sourcepos=\"99:1-99:169\">Then, open the SSH configuration file: <kbd>Ctrl<\/kbd> + <kbd>Shift<\/kbd> + <kbd>P<\/kbd> <code>Remote - SSH: Open SSH Configuration file<\/code> and restructure the host as follows:<\/p>\n<div class=\"gl-relative markdown-code-block js-markdown-code\">\n<pre id=\"code-17\" class=\"code highlight js-syntax-highlight language-plaintext white\" lang=\"plaintext\" data-canonical-lang=\"apacheconf\" data-sourcepos=\"101:1-110:3\"><code><span id=\"LC1\" class=\"line\" lang=\"plaintext\">Host container~*<\/span>\r\n<span id=\"LC2\" class=\"line\" lang=\"plaintext\">  RemoteCommand \/opt\/sw\/rev\/21.12\/haswell\/gcc-9.3.0\/singularity-3.8.5-p6gj6x\/bin\/singularity shell &lt;path_to_container&gt;<\/span>\r\n<span id=\"LC3\" class=\"line\" lang=\"plaintext\">  RequestTTY yes<\/span>\r\n<span id=\"LC4\" class=\"line\" lang=\"plaintext\"><\/span>\r\n<span id=\"LC5\" class=\"line\" lang=\"plaintext\">Host gwdg_mdc container~gwdg_mdc<\/span>\r\n<span id=\"LC6\" class=\"line\" lang=\"plaintext\">  HostName login-mdc.hpc.gwdg.de<\/span>\r\n<span id=\"LC7\" class=\"line\" lang=\"plaintext\">  User &lt;username&gt;<\/span>\r\n<span id=\"LC8\" class=\"line\" lang=\"plaintext\">  IdentityFile &lt;path_to_private_key&gt;\r\n<\/span><\/code><\/pre>\n<p>&nbsp;<\/p>\n<\/div>\n<p data-sourcepos=\"112:2-112:140\">Note: If you can enter the login node but singularity doesn&#8217;t run, try removing the &#8222;remote.SSH.remotePlatform&#8220; entry from <code>settings.json<\/code>.<\/p>\n<h2 data-sourcepos=\"112:2-112:140\">Author<\/h2>\n<p><a href=\"mailto:ali.doost-hosseini@gwdg.de\"><strong>Ali Doost Hosseini<\/strong><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>VSCode is a popular lightweight IDE developed by Microsoft that supports many programming languages and scripts. There are many features and capabilities that can be added to VSCode by installing extensions from the marketplace, including the ability to develop on a remote machine and manage files intuitively using its GUI. This document provides instructions for &#8230; <a title=\"Configuring VSCode to access GWDG&#8217;s HPC Cluster\" class=\"read-more\" href=\"https:\/\/info.gwdg.de\/news\/configuring-vscode-to-access-gwdgs-hpc-cluster\/\" aria-label=\"Mehr Informationen \u00fcber Configuring VSCode to access GWDG&#8217;s HPC Cluster\">Weiterlesen<\/a><\/p>\n","protected":false},"author":166,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[129],"tags":[],"class_list":["post-23262","post","type-post","status-publish","format-standard","hentry","category-wissenschaftliche-domaenen"],"_links":{"self":[{"href":"https:\/\/info.gwdg.de\/news\/wp-json\/wp\/v2\/posts\/23262","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/info.gwdg.de\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/info.gwdg.de\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/info.gwdg.de\/news\/wp-json\/wp\/v2\/users\/166"}],"replies":[{"embeddable":true,"href":"https:\/\/info.gwdg.de\/news\/wp-json\/wp\/v2\/comments?post=23262"}],"version-history":[{"count":18,"href":"https:\/\/info.gwdg.de\/news\/wp-json\/wp\/v2\/posts\/23262\/revisions"}],"predecessor-version":[{"id":23320,"href":"https:\/\/info.gwdg.de\/news\/wp-json\/wp\/v2\/posts\/23262\/revisions\/23320"}],"wp:attachment":[{"href":"https:\/\/info.gwdg.de\/news\/wp-json\/wp\/v2\/media?parent=23262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/info.gwdg.de\/news\/wp-json\/wp\/v2\/categories?post=23262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/info.gwdg.de\/news\/wp-json\/wp\/v2\/tags?post=23262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}