<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Boopathi Kumar Nachimuthu]]></title><description><![CDATA[AWS,Connect,Lambda,boto3,nodejs,python,code-snippets,ssh,server,ec2,s3,git,jenkins,devops,pyspark,bigdata]]></description><link>https://blogs.boopathikumar.me</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 18:00:55 GMT</lastBuildDate><atom:link href="https://blogs.boopathikumar.me/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Connect Oracle DB from AWS Lambda Using Node.js]]></title><description><![CDATA[In this article, You will find step by step guide to connect to Oracle DB using the library oracledb-for-lambda. The library will act as an Oracle client to use inside of Lambda.
At the time of writing this articles, the following library versions we...]]></description><link>https://blogs.boopathikumar.me/connect-oracle-db-from-aws-lambda-using-nodejs</link><guid isPermaLink="true">https://blogs.boopathikumar.me/connect-oracle-db-from-aws-lambda-using-nodejs</guid><category><![CDATA[aws lambda]]></category><category><![CDATA[Oracle]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[AWS]]></category><category><![CDATA[serverless]]></category><dc:creator><![CDATA[Boopathi Kumar Nachimuthu]]></dc:creator><pubDate>Mon, 19 Oct 2020 18:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1645561561978/Bu9CQ5XDb.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In this article, You will find step by step guide to connect to Oracle DB using the library <a target="_blank" href="https://www.npmjs.com/package/oracledb-for-lambda">oracledb-for-lambda</a>. The library will act as an Oracle client to use inside of Lambda.</p>
<p>At the time of writing this articles, the following library versions were used.</p>
<ol>
<li>Node – 8.10</li>
<li>oracledb-for-lambda: “^1.9.3-8a</li>
</ol>
<h3 id="heading-1-creating-bundle">1. Creating bundle</h3>
<p>The size of the library <code>oracledb_for_lambda</code> is more than 70 MB which is quite high for you to compile and upload to lambda every single time. Instead of that, You can bundle the lib and add it as a layer. So that we can include the layer directly to Lambda.</p>
<p>Creating this bundle will be our first step. You need to create the below folder structure before adding it to the layer.</p>
<p>First, Create a Node Js project using the below command</p>
<pre><code class="lang-javascript">npm init
</code></pre>
<p>Then Install the <code>oracledb_for_lambda</code> client by executing the below line</p>
<pre><code class="lang-javascript">npm i oracledb-<span class="hljs-keyword">for</span>-lambda
</code></pre>
<p>Now, In the Project folder, Create a folder named <code>nodejs</code> and You need to move the <code>node_modules</code> folder into this <code>nodejs</code> folder. Then, Copy the <code>lib</code> folder inside <code>/node_modules/oracledb-for-lambda</code> and paste it outside in the main project directory.</p>
<p>Finally, you will get a folder structure like the below image. That’s it, Zip the files inside the folder and Upload the Zip to S3.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1645558784695/n8xhsWK0A.png" alt="Connect Oracle DB from Lambda Using Node.js - Image 1" /></p>
<h3 id="heading-2-creating-the-layer">2. Creating the Layer</h3>
<p>As a next step, We are going to create the layer. Once the file is uploaded and available in S3, You can create a layer as described in the below screenshot.</p>
<p>Navigate to <code>Layers</code> and Click <code>Create Layer</code> button.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1645558818856/a-8R-YCmJ.png" alt="Connect Oracle DB from Lambda Using Node.js - Image 2" /></p>
<p>Then the <code>Layer Configuration</code> form opens. Here Provide the S3 link URL in which the Zip file is uploaded and create the layer.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1645558849397/VfHWCnwqj.png" alt="image-3.png" /></p>
<p>In the above screenshot, a layer with the name <code>oracle-client-node</code> is created</p>
<h3 id="heading-3-adding-the-layer-to-lambda">3. Adding the layer to Lambda</h3>
<p>After layer creation, You needs to add it to the Lambda. Open the Lamba function and Click <code>Layers</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1645558892096/qkAP0Aj3k.png" alt="image-4.png" /></p>
<p>In the <code>Layers</code> section, click the <code>Add a layer</code> button and Select the <code>oracle-client-node</code> layer created in the previous step.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1645558912084/Emk6u_o_R.png" alt="image-5.png" /></p>
<p>Once the layer is added to the Lambda function, You can view it in the <code>Layers</code> section as below.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1645558924286/oR0zqGcGG.png" alt="image-6.png" /></p>
<h3 id="heading-4-adding-hostalias">4. Adding Hostalias</h3>
<p>Next, You need to add host aliases pointing a hostname to localhost</p>
<p>But Lambda is something different here. The container (and the resources used by it) that runs our function is managed completely by AWS. It is <strong>made live when an event takes place and is turned off if it is not being used</strong>. If additional requests are made while the original event is being served, a new container is brought up to serve a request.</p>
<p>So, The hostname may change during every execution. For every execution the ephemeral disk space is available in the form of the /tmp directory. We can only use this space for temporary storage since subsequent invocations will not have access to this.</p>
<pre><code class="lang-javascript">str_host = os.hostname() + <span class="hljs-string">' localhost\n'</span>;
fs.writeFileSync(process.env.HOSTALIASES,str_host , <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>)</span>{
    <span class="hljs-keyword">if</span>(err) <span class="hljs-keyword">throw</span> err;
});
</code></pre>
<p>Using the above code we are getting the hostname of the execution container (and the resources used by lambda) and add hostaliases in the file <code>/tmp/HOSTALIASES</code></p>
<p>Also, add the <code>HOSTALIASES</code> key-value in Environment Variables like below</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1645558939195/wMXk5KgM4.png" alt="image-7.png" /></p>
<h3 id="heading-5-connecting-to-oracle-db">5. Connecting to Oracle DB</h3>
<p>Now we can use the below code to connect to Oracle DB from Lambda function.</p>
<pre><code class="lang-javascript"><span class="hljs-meta">'use strict'</span>;
<span class="hljs-keyword">var</span> os = <span class="hljs-built_in">require</span>(<span class="hljs-string">'os'</span>);
<span class="hljs-keyword">var</span> fs = <span class="hljs-built_in">require</span>(<span class="hljs-string">'fs'</span>);
<span class="hljs-keyword">var</span> oracledb = <span class="hljs-built_in">require</span>(<span class="hljs-string">'oracledb-for-lambda'</span>);
<span class="hljs-built_in">exports</span>.handler = <span class="hljs-keyword">async</span> (event, context) =&gt; {
    <span class="hljs-keyword">let</span> str_host = os.hostname() + <span class="hljs-string">' localhost\n'</span>;
    fs.writeFileSync(process.env.HOSTALIASES, str_host, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>) </span>{
        <span class="hljs-keyword">if</span> (err) <span class="hljs-keyword">throw</span> err;
    });
    <span class="hljs-keyword">var</span> connAttr = {
        <span class="hljs-attr">user</span>: process.env.USERNAME,
        <span class="hljs-attr">password</span>: process.env.PASSWORD,
        <span class="hljs-attr">connectString</span>: process.env.CONNECTION_STRING
    };

    <span class="hljs-keyword">const</span> promise = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">resolve, reject</span>) </span>{
        oracledb.getConnection(connAttr, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err, connection</span>) </span>{
            <span class="hljs-keyword">if</span> (err) {
                reject({
                    <span class="hljs-attr">status</span>: <span class="hljs-string">"ERROR"</span>
                });
            }
            resolve({
                <span class="hljs-attr">status</span>: <span class="hljs-string">"SUCCESS"</span>
            });
        });
    });
    <span class="hljs-keyword">return</span> promise;
}
</code></pre>
<p>In the above code, the values of USERNAME, PASSWORD, HOSTALIASES, and CONNECTION_STRING can be stored and retrieved from the environment variables.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1645558952720/kp_hNHqwM.png" alt="image-8.png" /></p>
<h3 id="heading-6-inserting-data-into-oracle-db">6. Inserting data into oracle DB</h3>
<p>Once the database connection is successful, You can use the below Node Js snippet to insert data to the database.</p>
<pre><code class="lang-javascript"><span class="hljs-meta">'use strict'</span>;
<span class="hljs-keyword">var</span> os = <span class="hljs-built_in">require</span>(<span class="hljs-string">'os'</span>);
<span class="hljs-keyword">var</span> fs = <span class="hljs-built_in">require</span>(<span class="hljs-string">'fs'</span>);
<span class="hljs-keyword">var</span> oracledb = <span class="hljs-built_in">require</span>(<span class="hljs-string">'oracledb-for-lambda'</span>);

<span class="hljs-built_in">exports</span>.handler = <span class="hljs-keyword">async</span> (event, context) =&gt; {
    <span class="hljs-keyword">let</span> str_host = os.hostname() + <span class="hljs-string">' localhost\n'</span>;
    fs.writeFileSync(process.env.HOSTALIASES, str_host, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>) </span>{
        <span class="hljs-keyword">if</span> (err) <span class="hljs-keyword">throw</span> err;
    });

    <span class="hljs-keyword">var</span> connAttr = {
        <span class="hljs-attr">user</span>: process.env.USERNAME,
        <span class="hljs-attr">password</span>: process.env.PASSWORD,
        <span class="hljs-attr">connectString</span>: process.env.CONNECTION_STRING
    };

    <span class="hljs-keyword">const</span> promise = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">resolve, reject</span>) </span>{
        <span class="hljs-keyword">try</span> {
            <span class="hljs-keyword">let</span> connection = <span class="hljs-keyword">await</span> oracledb.getConnection(connAttr); <span class="hljs-comment">//get connection</span>
            <span class="hljs-keyword">let</span> resultData = <span class="hljs-keyword">await</span> connection.execute(
                <span class="hljs-string">"INSERT INTO TABLE_NAME(COLUMN1,COLUMN2) VALUES (:1, :2)"</span>, [value1, value2], {
                    <span class="hljs-attr">autoCommit</span>: <span class="hljs-literal">true</span>
                },
                <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err, result</span>) </span>{
                    <span class="hljs-keyword">if</span> (err) {
                        resolve({
                            <span class="hljs-attr">status</span>: <span class="hljs-string">"ERROR"</span>
                        })
                    } <span class="hljs-keyword">else</span> {
                        resolve({
                            <span class="hljs-attr">status</span>: <span class="hljs-string">"SUCCESS"</span>
                        })
                    }
                });
        } <span class="hljs-keyword">catch</span> (err) {
            <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"DB Exception "</span> + err)
            resolve({
                <span class="hljs-attr">status</span>: <span class="hljs-string">"ERROR"</span>
            })
        }
    });
    <span class="hljs-keyword">return</span> promise;
}
</code></pre>
<h3 id="heading-7-fetching-the-values-from-oracle-db">7. Fetching the values from oracle DB</h3>
<p>Below snippet is used to fetch values from the database.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> promise = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">resolve, reject</span>) </span>{

    <span class="hljs-keyword">try</span> {
        <span class="hljs-keyword">let</span> connection = <span class="hljs-keyword">await</span> oracledb.getConnection(connAttr); <span class="hljs-comment">//get connection</span>
        <span class="hljs-keyword">let</span> resultData = <span class="hljs-keyword">await</span> connection.execute(
            <span class="hljs-string">"SELECT * FROM TABLE_NAME WHERE COLUMN1 = :1)"</span>, [value1],
            <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err, result</span>) </span>{
                <span class="hljs-keyword">if</span> (err) {
                    resolve({
                        <span class="hljs-attr">status</span>: <span class="hljs-string">"ERROR"</span>
                    })
                } <span class="hljs-keyword">else</span> {
                    resolve({
                        <span class="hljs-attr">status</span>: <span class="hljs-string">"SUCCESS"</span>
                    })
                }
            });
    } <span class="hljs-keyword">catch</span> (err) {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"DB Exception "</span> + err)
        resolve({
            <span class="hljs-attr">status</span>: <span class="hljs-string">"ERROR"</span>
        })
    }
});
<span class="hljs-keyword">return</span> promise;
});
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Manage multiple git accounts using SSH key authentication]]></title><description><![CDATA[Setting up and manage multiple git accounts as well as AWS CodeCommit using SSH key authentication 
Introduction
You may have multiple git accounts, one for official and one for personal, or when you work on cloud like AWS you may have many repositor...]]></description><link>https://blogs.boopathikumar.me/manage-multiple-git-accounts-using-ssh-key-authentication</link><guid isPermaLink="true">https://blogs.boopathikumar.me/manage-multiple-git-accounts-using-ssh-key-authentication</guid><category><![CDATA[GitHub]]></category><category><![CDATA[Windows]]></category><category><![CDATA[macOS]]></category><category><![CDATA[ssh]]></category><category><![CDATA[Productivity]]></category><dc:creator><![CDATA[Boopathi Kumar Nachimuthu]]></dc:creator><pubDate>Fri, 26 Jun 2020 18:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1645564824563/q8DD3VRV0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Setting up and manage multiple git accounts as well as AWS CodeCommit using SSH key authentication </p>
<h2 id="heading-introduction">Introduction</h2>
<p>You may have multiple git accounts, one for official and one for personal, or when you work on cloud like AWS you may have many repositories in different git accounts. At that time, You have to setup multiple usernames in the machine. But it is hard to change the settings every time. </p>
<p>You can solve the problem by setting the alias name for every git accounts. Yeah! Learn more on how to do that.</p>
<h2 id="heading-generate-ssh-key">Generate SSH Key</h2>
<p>First, we have to generate SSH key.For that, Open your <code>gitbash</code> terminal and navigate to required path/folder.Type the below command</p>
<pre><code class="lang-bash">ssh-keygen
</code></pre>
<p>Ssh-keygen is used to create authentication key pairs for SSH.Then provide the preferred file name for storing the key and press enter for remaining options.</p>
<pre><code class="lang-bash">$ ssh-keygen
Generating public/private rsa key pair.
Enter file <span class="hljs-keyword">in</span> <span class="hljs-built_in">which</span> to save the key (/c/Users/boopathikumar/.ssh/id_rsa): boopathi_rsa
Enter passphrase (empty <span class="hljs-keyword">for</span> no passphrase):
Enter same passphrase again:
Your identification has been saved <span class="hljs-keyword">in</span> boopathi_rsa.
Your public key has been saved <span class="hljs-keyword">in</span> boopathi_rsa.pub.
The key fingerprint is:
SHA256:7Nr/m0cI+tw+RWUR4JF0slTzGCg78BDw+YhW9nUTN2s boopathikumar@LAPTOP-B9TJ4GJ
The keys randomart image is:
+---[RSA 3072]----+
|      ....  .B*B+|
|       .o.. +.==B|
|        =+ o.o+E.|
|       = +=. .o. |
|      o S.oo o   |
|     . ..   . o  |
|        .o . o   |
|       o  o o..  |
|      . ...o=+   |
+----[SHA256]-----+
</code></pre>
<p>Now You can see two keys created as below in the path you have navigated in gitbash.</p>
<pre><code class="lang-bash">boopathi_rsa
boopathi_rsa.pub
</code></pre>
<h2 id="heading-adding-generated-ssh-key-in-github">Adding generated SSH Key in Github</h2>
<p>As a next step, You have to add SSH key into your Github account.Login to your Github account, navigate to <code>settings page</code> and click <code>SSH and GPG Keys</code> option and then press <code>New SSH Key</code> button.Provide a proper title and copy paste the content from <code>boopathi_rsa</code> file into the text box and save as shown below</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1644075414708/VzZPg_k5F.png" alt="github_profile.png" /></p>
<p>Once key is added, you can view the list of SSH keys in your accounts as below</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1644075435542/k1F4kYtNA.png" alt="github_profile_key_added.png" /></p>
<h2 id="heading-adding-ssh-key-in-aws-code-commit">Adding SSH Key in AWS Code Commit</h2>
<p>Now learn how to add the genrated SSH key into your AWS CodeCommit account.</p>
<p>Login to your AWS account and navigate to <code>IAM service</code> and open your IAM user. Under the <code>Security Credentials</code> tab you will find <code>Upload SSH public key</code> button. Click that and copy paste the content from <code>boopathi_rsa</code> file into the text box and save as shown below.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1644075452626/WlL-DJfpv.png" alt="aws_ssh_key.png" /></p>
<p>Once key is added you can see the below screen.Copy the <code>SSH key ID</code> for later use in below steps.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1644075535252/LevDYR6iu.png" alt="aws_ssh_key_saved.png" /></p>
<h2 id="heading-setup-configuration-file">Setup configuration file</h2>
<p>Till now, We have generated a SSH Key and added it to git. Create a folder in the name of <code>.ssh</code> inside your user folder.</p>
<p>Inside the <code>.ssh</code> folder, create a file in the name <code>config</code> with no extension. Now you will have the folder structure like below.</p>
<pre><code class="lang-bash">C:\Users\&lt;your-username&gt;\.ssh\config
</code></pre>
<p>The content of the <code>config</code> file should be added in the below format.</p>
<pre><code class="lang-bash">Host my.github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile <span class="hljs-string">"C:/Users/boopathikumar/.ssh/boopathi_rsa"</span>

Host office.github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile <span class="hljs-string">"C:/Users/boopathikumar/.ssh/boopathi_rsa2"</span>

Host my_codecommit
    Hostname git-codecommit.us-east-1.amazonaws.com (only access to repo <span class="hljs-keyword">in</span> us-east-1)
    User  APKAVDUCNF4JYDGHGTNQ (copied SSH key ID)
    PreferredAuthentications publickey
    IdentityFile <span class="hljs-string">"C:/Users/CloudKinetics/.ssh/boopathi_rsa"</span>

Host office_codecommit
    Hostname git-codecommit.*.amazonaws.com (to access all region)
    User  XXXXXXXXXXXXXXXXXXXX  
    PreferredAuthentications publickey
    IdentityFile <span class="hljs-string">"C:/Users/CloudKinetics/.ssh/boopathi_rsa"</span>
</code></pre>
<p>In the above configuration, meaning of each term is shown below</p>
<ul>
<li><code>Host</code> - Provide a alias name for your git account. This will be used instead of hostname.</li>
<li><code>Hostname</code> - Actual git account hostname</li>
<li><code>User</code> - This is needed only for AWS code commit</li>
<li><code>PreferredAuthentications</code> - To authorize with SSH key, Provide the value as <code>publickey</code></li>
<li><code>IdentityFile</code> - Path of you pem key</li>
</ul>
<p>Now all the configurations are completed. You can clone the repository from any account.</p>
<h2 id="heading-clone-the-repository">Clone the Repository</h2>
<p>Now I am trying to clone the private repository from my personal github account.For that, get the SSH clone URL of the repository as show below</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1644075559248/dHkWAb2wF.png" alt="git_clone.png" /></p>
<p>The SSH Clone URL looks like the below</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> git@github.com:boopathikumar018/sample_repo.git
</code></pre>
<p>In that,Change the <code>host name (github.com)</code> to configured <code>Alias host name (my.github.com)</code> now the you URL will be like</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> git@my.github.com:boopathikumar018/sample_repo.git
</code></pre>
<p>Once you execute the clone command, repository will be automatically cloned using the credentials provided under the Alias name in <code>config</code> file</p>
<p>Now I am trying to clone the AWS code commit repository from my AWS account.For that get the SSH Clone URL of the repository as show below</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1644075588442/PtDF_vLLk.png" alt="aws_clone.png" /></p>
<p>you will get a clone SSH URL of the repository like below</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/sample-repo
</code></pre>
<p>In this also, Change the <code>host name (git-codecommit.us-east-1.amazonaws.com)</code> to configured <code>Alias name (my_codecommit)</code> now the you URL will be like</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> ssh://my_codecommit/v1/repos/sample-repo
</code></pre>
<p>This will automatically clone the repo using the credentials configured under the Alias name in the <code>config</code> file</p>
<p>Like this, You can configure as many git account as you want and use easily by just changing to <code>Alias name</code>.</p>
]]></content:encoded></item><item><title><![CDATA[Write and execute code directly in remote machines using VS Code]]></title><description><![CDATA[Access remote machines, develop and execute code in it, read log files, everything directly from VS Code using the most useful plugin "Remote-SSH"
Introduction
Now most of the developers using Visual Studio Code for development. And it provides vario...]]></description><link>https://blogs.boopathikumar.me/write-and-execute-code-directly-in-remote-machines-using-vs-code</link><guid isPermaLink="true">https://blogs.boopathikumar.me/write-and-execute-code-directly-in-remote-machines-using-vs-code</guid><category><![CDATA[Visual Studio Code]]></category><category><![CDATA[Productivity]]></category><category><![CDATA[ssh]]></category><category><![CDATA[vscode extensions]]></category><category><![CDATA[programing]]></category><dc:creator><![CDATA[Boopathi Kumar Nachimuthu]]></dc:creator><pubDate>Thu, 25 Jun 2020 18:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1644076344392/KONXL8We4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Access remote machines, develop and execute code in it, read log files, everything directly from VS Code using the most useful plugin "Remote-SSH"</p>
<h2 id="heading-introduction">Introduction</h2>
<p>Now most of the developers using Visual Studio Code for development. And it provides various plugin to make developers code comfortably. I am writing this blog about one of my favourite plugin <a target="_blank" href="https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh">Remote - SSH</a> which I am using every time to update code in remote server and check logs by running <code>grep</code> command in large log files and export the required contents in separate file and view easily. All these things can be done directly from the Visual Studio Code instead of connecting through a Putty terminal.</p>
<h2 id="heading-installation-andamp-configure">Installation &amp; Configure</h2>
<p>Install <a target="_blank" href="https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh">Remote - SSH</a> from the Microsoft marketplace. After successful installation, You can find the "Remote Explorer" icon in the left navigation.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1644057669088/-yxnAtdIK.png" alt="After Install" /></p>
<p>After installing the plugin, we need to create a config file with the list of remote server details which you wish to connect.Create a file in the below mentioned path with name <code>sshConfig</code> (without any extension)</p>
<blockquote>
<p>Note : If you didn't have <code>.ssh</code> folder create new folder and enter name as <code>.ssh.</code> and save it</p>
</blockquote>
<pre><code class="lang-bash">C:\Users\&lt;your-username&gt;\.ssh\sshConfig
</code></pre>
<p>Provide the remote server details inside the <code>sshConfig</code> file in the below mentioned format</p>
<pre><code class="lang-bash">Host dev
    HostName XXX.XX.XX.XXX
    User ubuntu
    IdentityFile <span class="hljs-string">"C:/Users/boopathikumar/.ssh/ubuntu.pem"</span>

Host prod
    HostName XXX.XX.XX.XXX
    User ubuntu
    IdentityFile <span class="hljs-string">"C:/Users/boopathikumar/.ssh/ubuntu.pem"</span>
</code></pre>
<p>Meaning of the terms used in the above format is explained below</p>
<ul>
<li><code>Host</code> - Provide any name for your remote server for further reference.</li>
<li><code>Hostname</code> - Remote server Ip address</li>
<li><code>User</code> - Username for login into the server</li>
<li><code>IdentityFile</code> - Path of you pem key</li>
</ul>
<p>Then select the <code>settings icon</code> near <code>SSH TARGETS</code> and add the <code>sshConfig</code> file path which we had created previously.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1644057713225/A1K9Al_mG.png" alt="Add configuration file" /></p>
<p>After that you can see the list of remote servers configured in the <code>sshConfig</code> file inside the Visual Studio Code as shown below</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1644057744601/G2BGPRK79.png" alt="List servers" /></p>
<h1 id="heading-connect-server">Connect server</h1>
<p>To connect to any particular server, Click on the folder icon next to the remote server name as highlighted below.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1644057808741/6i1Ru2o2G.png" alt="Connect servers" /></p>
<p>Then, Select the Operating system of the remote server.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1644057838078/-rzEa8knR.png" alt="Connect servers select OS" /></p>
<p>Once the server is connected, You can see the name of the host which you provided on <code>sshConfig</code> file on the bottom left corner.</p>
<p>Click on <code>Open folder</code> button to view the folders in the remote server.Select the folder that you need to view as shown below</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1644057869254/wyCLFrGFH.png" alt="Connect servers select OS" /></p>
<p>After that you can view files under selected remote folder on the explorer as shown below.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1644057900434/L9Z0xzokx.png" alt="Connected" /></p>
<p>Also you can use the <code>integrated terminal</code> to run the commands on connected remote server directly.</p>
<p>Setup "Remote - SSH" and enjoy programming in a remote server directly from Visual Studio Code !!!.</p>
]]></content:encoded></item></channel></rss>