<?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: MG</title>
    <description>The latest articles on DEV Community by MG (@the_dark_code).</description>
    <link>https://dev.to/the_dark_code</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%2F177687%2Fd868c372-773a-4376-ad11-61e1bb83bd4e.jpeg</url>
      <title>DEV Community: MG</title>
      <link>https://dev.to/the_dark_code</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/the_dark_code"/>
    <language>en</language>
    <item>
      <title> Free VPN for 1 Year </title>
      <dc:creator>MG</dc:creator>
      <pubDate>Sun, 06 Dec 2020 10:41:20 +0000</pubDate>
      <link>https://dev.to/the_dark_code/free-vpn-for-1-year-2an8</link>
      <guid>https://dev.to/the_dark_code/free-vpn-for-1-year-2an8</guid>
      <description>&lt;p&gt;In this article, I am going to setup a free VPN server and I will use this server for my personal use for 1 year. &lt;/p&gt;

&lt;p&gt;Prerequisite: &lt;br&gt;
Setup AWS account(which comes with a Free Tier Eligibility for 12 months)&lt;/p&gt;

&lt;p&gt;Now before starting you need to decide in which region you want to host the VPN server&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkud4cwnl9i4ucurykg3z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkud4cwnl9i4ucurykg3z.png" alt="Screenshot 2020-12-06 at 1.14.02 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can check latency across different regions and decide accordingly, and if you have any certain reasons like in my case, some of the Anime on Netflix is only allowed in USA regions so I decided to host my VPN server in the US 😛&lt;/p&gt;
&lt;h2&gt;
  
  
  Let’s start
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fq8b57lthwv8zydmjuz7m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fq8b57lthwv8zydmjuz7m.png" alt="Screenshot 2020-12-06 at 12.37.50 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open EC2 service in AWS&lt;/li&gt;
&lt;li&gt;Change region from the top to the region where you want to host the VPN server&lt;/li&gt;
&lt;li&gt;Click on Launch Instance&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhnkecv0o7pia1dxprs8k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhnkecv0o7pia1dxprs8k.png" alt="Screenshot 2020-12-06 at 12.39.14 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, it will ask you to choose AMI,&lt;/p&gt;

&lt;p&gt;We will be using ubuntu machine which already has OpenVPN server installed, so you need to select &lt;strong&gt;AWS Marketplace&lt;/strong&gt; and search &lt;strong&gt;OpenVPN&lt;/strong&gt;, then you have to select &lt;strong&gt;OpenVPN access server&lt;/strong&gt; which has &lt;strong&gt;Free tier eligible&lt;/strong&gt; tag&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5aqk74ohgrkz3s8gf224.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5aqk74ohgrkz3s8gf224.png" alt="Screenshot 2020-12-06 at 12.41.30 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;OpenVPN is a free and Open Source VPN, but it’s a commercial service but although we can be allowed to open two VPN accounts for free without being charged anything using the Bring Your Own License(BYOL) option and that’s the essence of the page being displayed here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbau3qcv063fhtkm1jznc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbau3qcv063fhtkm1jznc.png" alt="Screenshot 2020-12-06 at 12.41.47 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose an Instance Type&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select t2.micro which has &lt;code&gt;Free tier eligible&lt;/code&gt; tag&lt;/li&gt;
&lt;li&gt;Click on "Review and Launch"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8f6xvl4mou18f9hny8z6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8f6xvl4mou18f9hny8z6.png" alt="Screenshot 2020-12-06 at 12.42.39 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select Launch&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7p1r9bpv5qen6pjclnyo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7p1r9bpv5qen6pjclnyo.png" alt="Screenshot 2020-12-06 at 12.43.04 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you will see a pop-up like above&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose &lt;code&gt;Create a new key pair&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type key pair name(which can be any string)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Download key pair(Note: It is important to Save this file properly, you will need this file to ssh to this machine)&lt;/strong&gt;  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Launch Instance&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdp87kgwik9dcj3iu7w9u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdp87kgwik9dcj3iu7w9u.png" alt="Screenshot 2020-12-06 at 12.43.48 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fawnjo0v2cyflny09nnkm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fawnjo0v2cyflny09nnkm.png" alt="Screenshot 2020-12-06 at 12.44.53 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now connect to this instance by choosing to connect&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcnilvm4i3z97ful0ljgv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcnilvm4i3z97ful0ljgv.png" alt="Screenshot 2020-12-06 at 12.45.25 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the SSH-client tab, you will see how to connect to this machine using SSH&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fsbdkmudbjchmvz6amgy0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fsbdkmudbjchmvz6amgy0.png" alt="Screenshot 2020-12-06 at 12.53.48 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open terminal or PowerShell&lt;/li&gt;
&lt;li&gt;Change the permission of the private key file if required&lt;/li&gt;
&lt;li&gt;Now SSH to the machine as a root user in order to configure the admin side of the VPN
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -i "/&amp;lt;path_of_the_file&amp;gt;/&amp;lt;your-key-pair&amp;gt;" root@&amp;lt;your-public-instance-domain&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg3bp369lffdqwzpwxj80.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg3bp369lffdqwzpwxj80.png" alt="Screenshot 2020-12-06 at 1.00.24 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Press yes and enter&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fm3nvfrm2ofq7o0tfkqsk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fm3nvfrm2ofq7o0tfkqsk.png" alt="Screenshot 2020-12-06 at 1.02.33 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now keep pressing enter if you want to have a default setting for VPN&lt;/p&gt;

&lt;p&gt;After it's done you’ll see an instruction to no longer login as root but as user &lt;code&gt;openvpnas&lt;/code&gt; which is created by default.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F62sak1nwkqd0wmz5xh8j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F62sak1nwkqd0wmz5xh8j.png" alt="Screenshot 2020-12-06 at 1.04.20 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now SSH to the instance again, but not as root but as user “openvpnas” using the command below:&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;path_of_the_file&amp;gt;/&amp;lt;your-key-pair&amp;gt;" openvpnas@&amp;lt;your-public-instance-domain&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have to create a password for this user so that you can access the admin and client page of the OpenVPN portal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo passwd openvpn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fiy1j6qboio192nd001q9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fiy1j6qboio192nd001q9.png" alt="Screenshot 2020-12-06 at 1.05.12 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now get the public IP of the instance and type in the browser&lt;br&gt;
like below:&lt;br&gt;
&lt;code&gt;http://&amp;lt;public IP address&amp;gt;:943/admin&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Enter username -&amp;gt; &lt;code&gt;openvpn&lt;/code&gt;, password -&amp;gt; &lt;/p&gt;

&lt;p&gt;Click sign in&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fns3fz2e4212lccznzts3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fns3fz2e4212lccznzts3.png" alt="Screenshot 2020-12-06 at 1.05.28 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Agree on T&amp;amp;C&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fezym09jrrfx33kq7f1wt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fezym09jrrfx33kq7f1wt.png" alt="Screenshot 2020-12-06 at 1.05.47 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now on this page, select &lt;code&gt;VPN setting&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdn71kykteavq5a3omu82.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdn71kykteavq5a3omu82.png" alt="Screenshot 2020-12-06 at 1.06.21 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Scroll down and find &lt;code&gt;Should client Internet traffic be routed through the VPN?&lt;/code&gt; and enable this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqpyjpz1wf4qqgiov90yt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqpyjpz1wf4qqgiov90yt.png" alt="Screenshot 2020-12-06 at 1.06.29 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Scroll down and save the settings&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5769epodsqttwb2lgc6t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5769epodsqttwb2lgc6t.png" alt="Screenshot 2020-12-06 at 1.06.38 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you change the settings, you’ll need to update the server, so click on “Update Running Server”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3l1x89zrl3qucj4cyuhf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3l1x89zrl3qucj4cyuhf.png" alt="Screenshot 2020-12-06 at 1.07.05 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now to connect to this VPN, go to a new tab in browser and type&lt;br&gt;
&lt;code&gt;http://&amp;lt;public IP address&amp;gt;:943/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwfynd39jxaw9y8wbtdv8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwfynd39jxaw9y8wbtdv8.png" alt="Screenshot 2020-12-06 at 1.07.20 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose a device for which you want to download OpenVPN client&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvnynz15dchzd6ga719w5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvnynz15dchzd6ga719w5.png" alt="Screenshot 2020-12-06 at 1.08.42 PM"&gt;&lt;/a&gt;&lt;br&gt;
I downloaded for mac device and installed it now open the app and click on + icon&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7giq53rbkae8bunjzzqh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7giq53rbkae8bunjzzqh.png" alt="Screenshot 2020-12-06 at 1.08.59 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now enter the public IP address of the ec2 machine&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcik98zml4iy12u26ujzh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcik98zml4iy12u26ujzh.png" alt="Screenshot 2020-12-06 at 1.09.18 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter username and password(It is same that you used to login for admin panel) &lt;br&gt;
Congrats, Now you have successfully connected to the VPN&lt;/p&gt;

&lt;p&gt;You can also check your IP by googling &lt;code&gt;what is my IP&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;

</description>
      <category>privacy</category>
      <category>aws</category>
      <category>productivity</category>
      <category>programming</category>
    </item>
    <item>
      <title>Asynchronous Programming in python with AsyncIO(For Beginners) 
</title>
      <dc:creator>MG</dc:creator>
      <pubDate>Sun, 18 Oct 2020 11:28:02 +0000</pubDate>
      <link>https://dev.to/the_dark_code/asyncio-for-beginners-fdj</link>
      <guid>https://dev.to/the_dark_code/asyncio-for-beginners-fdj</guid>
      <description>&lt;p&gt;In this article, I will explain asynchronous programming in Python via AsyncIO library.&lt;/p&gt;

&lt;p&gt;Before going forward let’s understand few terminologies&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Event loops&lt;/strong&gt;: It is used to run asynchronous tasks(which can be a coroutine, a future or any awaitable objects) concurrently, it can register the task which is going to be executed, execute them, delay or cancel them&lt;/p&gt;

&lt;p&gt;Suppose we have 2 async tasks(task1 and task2) now I schedule both tasks on event loop now suppose event loop starts executing task1 and encounter an IO operation then it will take back the control from task 1 and give it to task2 to execute and when the task1 completes IO and when the control comes back to task1 it will resume from the state it was stopped thus two or more tasks can concurrently run together&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Awaitable objects&lt;/strong&gt;: We say that an object is an awaitable object if it can be used in an await or yield from expression.&lt;/p&gt;

&lt;p&gt;There are three main types of awaitable objects in python: coroutines, Tasks, and Futures.&lt;/p&gt;

&lt;h3&gt;
  
  
  AsyncIO(Asynchronous input-output)
&lt;/h3&gt;

&lt;p&gt;AsyncIO is a library which helps to run code concurrently using single thread or event loop, It is basically using async/await API for asynchronous programming.&lt;/p&gt;

&lt;p&gt;AsyncIO was released in python 3.3 before that we use threads, greenlet and multiprocessing library to achieve asynchronous programming in python&lt;/p&gt;

&lt;h4&gt;
  
  
  Why do we need AsyncIO for asynchronous programming?
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;As threads can be used for running several tasks concurrently but python threads are managed by Operating system and OS have to do more context switching b/w threads compared to green threads&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Greenlet(green threads) takes away the scheduler from the OS and playing the scheduler itself but CPython doesn’t use green threads by default (this is what asyncio, gevent, PyPy, et al. are for)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;By using Multiprocessing library we can create multiple processes and we can allow the program to make full use of all cores of the computer but processes are costly to spawn so for I/O operations, threads are chosen largely&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In General, asyncIO is a more readable and cleaner approach towards asynchronous programming.&lt;/p&gt;

&lt;h4&gt;
  
  
  How to use asyncIO?
&lt;/h4&gt;

&lt;p&gt;When asyncIO released it was using &lt;code&gt;@asyncio.coroutine&lt;/code&gt; decorator with &lt;code&gt;generator-based coroutines&lt;/code&gt; to achieve asynchronous programming&lt;/p&gt;

&lt;p&gt;Asyncio generator coroutines use &lt;code&gt;yield from&lt;/code&gt; syntax to suspend coroutine.&lt;/p&gt;

&lt;p&gt;In the below example &lt;code&gt;some_async_task()&lt;/code&gt; is a generator-based coroutine, to execute this coroutine, first, we need to get the event loop(at line 11) and then schedule this task to run in an event loop using(loop.run_until_complete) &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Directly calling &lt;code&gt;some_async_task()&lt;/code&gt; will not schedule this task to execute, it will only return a generator object&lt;/p&gt;
&lt;/blockquote&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;Here in line 8 &lt;code&gt;asyncio.sleep()&lt;/code&gt; is a coroutine(we can use any coroutine or tasks/future here)and when the statement yield from executed it which will give up the control back to the event loop to let other coroutines execute and when coroutine &lt;code&gt;asyncio.sleep()&lt;/code&gt; completed and when the event loop gives back the control to &lt;code&gt;some_async_task()&lt;/code&gt; coroutine it will run further instruction(like line 9)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;In Python 3.5 the language introduced native support for coroutines. Now we can use async/await syntax to define native coroutines&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;A method prefixed with &lt;code&gt;async def&lt;/code&gt; automatically becomes a native coroutine.&lt;br&gt;
&lt;code&gt;await&lt;/code&gt; can be used to obtain the result of awaitable objects(which can be coroutine, tasks or future)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  How to run the event loop?
&lt;/h4&gt;

&lt;p&gt;Before python 3.7 we manually create/get event loop and then schedule our task like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;loop = asyncio.get_event_loop() #if there is no event loop then it will create new one. 
loop.run_until_complete(coroutine()) #run until coroutine is completed.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In python 3.7 and above, below is the preferred way to run the event loop&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;asyncio.run(coroutine())
# This function runs the passed coroutine, taking care of managing the asyncio event loop and finalizing asynchronous generators.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;AsyncIO provides high-level API and low-level APIs, generally, application developer use high-level API and library or framework developer uses low-level API&lt;/p&gt;
&lt;h4&gt;
  
  
  Futures in Asyncio
&lt;/h4&gt;

&lt;p&gt;It is a low-level awaitable object that is supposed to have a result in the future.&lt;/p&gt;

&lt;p&gt;when a future object is awaited it means that the coroutine will wait until the Future is resolved in some other place.&lt;/p&gt;

&lt;p&gt;This API exists to enable callback-based code to be used with async/await&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Normally at the application level code, we don't deal with Future objects, it is usually exposed by asyncio API or libraries.&lt;/p&gt;

&lt;h4&gt;
  
  
  Tasks in AsyncIO
&lt;/h4&gt;

&lt;p&gt;Task is a subclass of futures and it is used to run coroutines concurrently within an event loop.&lt;br&gt;
There are many ways to create a task:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;loop.create_task() → via low-level API and it only accepts coroutines.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;asyncio.ensure_future() → via low-level API and it can accept any awaitable objects, this will work on all python version but it is less readable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;asyncio.create_task() → via high-level API and it is work in Python 3.7+ and it accepts coroutines and it will wrap them as tasks&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h5&gt;
  
  
  asyncio.create_task()
&lt;/h5&gt;

&lt;p&gt;When a coroutine is wrapped into a Task with functions like &lt;code&gt;asyncio.create_task()&lt;/code&gt; the coroutine is automatically scheduled to run soon&lt;br&gt;
In Below example I am using &lt;code&gt;aiohttp&lt;/code&gt; library to fetch news articles from hacker-news public APIs, i created two task(task1 and task 2) to fetch two different news concurrently and showing the title for both news article.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h5&gt;
  
  
  asyncio.ensure_future()
&lt;/h5&gt;

&lt;p&gt;It is similar to asyncio.create_task() but it can also accept the future as shown in the below example&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h5&gt;
  
  
  asyncio.gather(*awaitable_objects, return_exceptions)
&lt;/h5&gt;

&lt;p&gt;It is responsible for gathering all the results, it will wait till all the awaitables objects are completed and return the results in order of given awaitable objects&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;If there is an exception in any of the awaitable object, it will not cancel the other awaitable objects&lt;br&gt;
In the below example we are running two tasks concurrently and we can see that if there is an exception in &lt;code&gt;some_async_task2()&lt;/code&gt;, it won't cancel &lt;code&gt;some_async_task()&lt;/code&gt; coroutine&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;If &lt;code&gt;return_exceptions&lt;/code&gt; is &lt;code&gt;False&lt;/code&gt; and if there is any exception raised in any of awaitable object then the await &lt;code&gt;asyncio.gather()&lt;/code&gt; returns immediately and show an error to the screen. so for demo purpose at line 17, we are awaiting another coroutine(which will resolve after 6 sec) to make sure that program doesn't exit as after 4 sec&lt;/p&gt;

&lt;p&gt;And we can see the execution of line 6 in the output&lt;/p&gt;

&lt;p&gt;If we want to gather all the result(along with exception) in an array then we can use &lt;code&gt;return_exceptions=True&lt;/code&gt; which will treat exception as a result and it will be aggregated in the result list.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  That's it for now, In Future, I will write about how can we utilize this AsyncIO library in Django along with ASGI
&lt;/h3&gt;

</description>
      <category>asyncio</category>
      <category>python</category>
      <category>asynchronous</category>
      <category>django</category>
    </item>
  </channel>
</rss>
