<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rahul</title>
    <description>The latest articles on DEV Community by Rahul (@ask_rpc).</description>
    <link>https://dev.to/ask_rpc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F381423%2F5d7b9ca5-3f49-43cd-9d33-f97b13c426de.png</url>
      <title>DEV Community: Rahul</title>
      <link>https://dev.to/ask_rpc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ask_rpc"/>
    <language>en</language>
    <item>
      <title>How to use VS Code for remote development behind corporate network</title>
      <dc:creator>Rahul</dc:creator>
      <pubDate>Sun, 24 May 2020 15:09:57 +0000</pubDate>
      <link>https://dev.to/ask_rpc/how-to-use-vs-code-for-remote-development-behind-corporate-network-1nk3</link>
      <guid>https://dev.to/ask_rpc/how-to-use-vs-code-for-remote-development-behind-corporate-network-1nk3</guid>
      <description>&lt;p&gt;The basic setup is like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;your workstation &amp;lt;=&amp;gt; remote server/workstation&lt;/li&gt;
&lt;li&gt;your workstation &amp;lt;=&amp;gt; a jump host &amp;lt;=&amp;gt; remote server/workstation&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;VS code will ssh into the remote server and you can open your development folder. It would be as if the files are in your local machine.&lt;/p&gt;

&lt;p&gt;Case 1 is pretty straight forward. If you do not have a jump host in between then go to step 2.&lt;br&gt;
For Case 2, you need to create a tunnel.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1.
&lt;/h2&gt;

&lt;p&gt;Creating a tunnel.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -i &amp;lt;private key&amp;gt; &amp;lt;jump host username&amp;gt;@&amp;lt;jumphost&amp;gt; -L localhost:22:&amp;lt;remote_server&amp;gt;:22 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;private key is the one whose public pair is added to the jump host. What this does is that it creates a  tunnel and informs ssh to send the traffic on port 22 of localhost to port 22 of remote_server.&lt;/p&gt;

&lt;p&gt;After this you should easily be able to login to your remote_server&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh &amp;lt;remote server username&amp;gt;@localhost
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent"&gt;Create&lt;/a&gt; an ssh pair if you don't already have one.&lt;br&gt;
Now login to remote ssh server, and edit ~/.ssh/authorized_keys and paste the contents of .pub file.&lt;br&gt;
*.pub is a public file that you are sharing with the server. Do not share the private key with anyone. The private file with have private mentioned in it, public won't.&lt;/p&gt;

&lt;p&gt;This allows you to ssh from your local to server without entering password.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step3:
&lt;/h2&gt;

&lt;p&gt;Make sure you have installed VS code and have &lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh"&gt;Remote-SSH&lt;/a&gt; extension installed.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 4
&lt;/h2&gt;

&lt;p&gt;Now we need to create a config file that will tell VS code to use the ssh file when logging in to the remote server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cat config
Host localhost
  HostName localhost
  IdentityFile C:\Users\&amp;lt;user&amp;gt;\.ssh\&amp;lt;id_rsa&amp;gt;
  User &amp;lt;user name for remote&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;IdentityFile is the location of private file.&lt;br&gt;
Save it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step5
&lt;/h2&gt;

&lt;p&gt;Add config file to VS code extension settings.&lt;br&gt;
In settings, type: @ext:ms-vscode-remote.remote-ssh&lt;br&gt;
In Remote SSH: Config File&lt;br&gt;
enter the absolute path of the config file we created in Step 4.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 6.
&lt;/h2&gt;

&lt;p&gt;Now we need to connect. Click on lower green button "&amp;gt;&amp;lt;" that says "open a remote window"&lt;br&gt;
It will open the usual context menu.&lt;br&gt;
"Remote-SSH: Connect to remote Host..."&lt;br&gt;
type: remote_username@localhost&lt;/p&gt;

&lt;p&gt;This will establish a connection to your remote server and install VS code terminal. It will ask which machine. Select from Linux, Windows, Mac. After that you are ready.&lt;/p&gt;

&lt;p&gt;Installing VS code server needs internet connection, so if your server has internet connection off then you need to follow step 7. &lt;/p&gt;
&lt;h2&gt;
  
  
  Step 7. Manually setup VS code on remote server
&lt;/h2&gt;

&lt;p&gt;ssh to remote server. &lt;br&gt;
Download the latest server package from &lt;a href="https://update.code.visualstudio.com/latest/server-linux-x64/stable"&gt;https://update.code.visualstudio.com/latest/server-linux-x64/stable&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SCP the file to the server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cd ~/.vscode-server/bin/
5763d909d5f12fe19f215cbfdd29a91c0fa9208a  # &amp;lt;-- is the commit id
# delete all the files in this directory
$ tar -xvzf vscode-server-linux-x64.tar.gz --strip-components 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Follow Step 6 again.&lt;br&gt;
You are now ready to for development ready.&lt;/p&gt;

&lt;p&gt;Please mention if any step was not clear. I would have attached images but Dev doesn't support uploading images (teach if you know how to).&lt;/p&gt;

&lt;p&gt;Follow me on &lt;a href="https://twitter.com/ask_rpc"&gt;@ask_rpc&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
