<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Server &#8211; Otricks.com</title>
	<atom:link href="https://otricks.com/category/server/feed/" rel="self" type="application/rss+xml" />
	<link>https://otricks.com</link>
	<description>It&#039;s the big &#039;O&#039; in technology</description>
	<lastBuildDate>Sun, 09 Jan 2022 20:40:26 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
	<item>
		<title>Steps to open port 25 on EC2 instance &#8211; Amazon web service (AWS)</title>
		<link>https://otricks.com/steps-to-open-port-25-on-ec2-instance-amazon-web-service-aws/</link>
		
		<dc:creator><![CDATA[Anjum Nawab]]></dc:creator>
		<pubDate>Sun, 09 Jan 2022 08:51:51 +0000</pubDate>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[Server]]></category>
		<guid isPermaLink="false">https://otricks.com/?p=2420</guid>

					<description><![CDATA[<p>When you create new EC2 instance (server) on AWS you own everything, including what is open to public and what is not, with one exception&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://otricks.com/steps-to-open-port-25-on-ec2-instance-amazon-web-service-aws/">Steps to open port 25 on EC2 instance &#8211; Amazon web service (AWS)</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>When you create new EC2 instance (server) on AWS you own everything, including what is open to public and what is not, with one exception port 25, You can&#8217;t open this port without AWS help. They have valid reasons to block it, as some bad people use EC2 to spam. </p>



<p>You can open other ports using &#8212;&gt; Network &amp; Security  &#8212;&gt; Security Groups</p>



<figure class="wp-block-image size-large"><img decoding="async" src="https://otricks.com/wp-content/uploads/2022/01/Screen-Shot-2022-01-09-at-11.44.28-AM-983x1024.png" alt="" class="wp-image-2421"/></figure>



<h2 class="wp-block-heading">Request to open </h2>



<p>Goto top right side inside AWS account, and click on ? mark icon, it will open dropdown and click on<strong><em> support center</em></strong>.</p>



<p> </p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="797" src="https://otricks.com/wp-content/uploads/2022/01/Screen-Shot-2022-01-09-at-11.56.18-AM-1024x797.png" alt="" class="wp-image-2454" srcset="https://otricks.com/wp-content/uploads/2022/01/Screen-Shot-2022-01-09-at-11.56.18-AM-1024x797.png 1024w, https://otricks.com/wp-content/uploads/2022/01/Screen-Shot-2022-01-09-at-11.56.18-AM-300x234.png 300w, https://otricks.com/wp-content/uploads/2022/01/Screen-Shot-2022-01-09-at-11.56.18-AM-768x598.png 768w, https://otricks.com/wp-content/uploads/2022/01/Screen-Shot-2022-01-09-at-11.56.18-AM.png 1444w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>It will take you to AWS Support Center page. click on <a href="https://console.aws.amazon.com/support/home#/case/create">Create case</a> it will take you to the page with three radio button options, you need to select <strong><em>Server limit increase </em></strong>it will open search field, you will need to search with &#8220;ec2 email&#8221; and last click on EC2 email external link, as shown in below image.</p>



<figure class="wp-block-image size-large"><img decoding="async" src="https://otricks.com/wp-content/uploads/2022/01/Screen-Shot-2022-01-09-at-12.04.06-PM-1024x583.png" alt="" class="wp-image-2424"/></figure>



<p>You need to provide details like below.</p>



<p></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Hello Amazonian</p><p>I will use Amazon SES to send email to reset passwords in case they request password reset. The email will always have an unsubscribe link that they can request to be removed from our list.</p><p>My web server is based in openSource technology which comes with below services to protect from spamming etc<br>Amavisd-new,<br>SpamAssassin,<br>ClamAV<br>Kindly approve my request for Amazon SES production access in the above mentioned region. Let me know if you have any questions.</p><p>Thanks</p></blockquote>



<figure class="wp-block-image size-large"><img decoding="async" src="https://otricks.com/wp-content/uploads/2022/01/Screen-Shot-2022-01-09-at-12.11.41-PM-790x1024.png" alt="" class="wp-image-2425"/></figure>



<p>They are very fast to response, I often get in without 1 hour.</p>



<p>Hope you like this small post, if its helpful please share it on social media. </p>



<p></p>



<p>You may like other post too </p>



<p></p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:100%">
<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow"><ul class="wp-block-latest-posts__list is-grid columns-3 wp-block-latest-posts"><li><a class="wp-block-latest-posts__post-title" href="https://otricks.com/steps-to-open-port-25-on-ec2-instance-amazon-web-service-aws/">Steps to open port 25 on EC2 instance &#8211; Amazon web service (AWS)</a></li>
<li><a class="wp-block-latest-posts__post-title" href="https://otricks.com/create-front-end-app-for-space-xyz-cargo-booking-system/">Create front-end app for space-XYZ cargo booking system.</a></li>
<li><a class="wp-block-latest-posts__post-title" href="https://otricks.com/how-to-use-websocket-socket-io-inside-strapi-content-management-system/">How to use webSocket/Socket.io inside Strapi content management system.</a></li>
<li><a class="wp-block-latest-posts__post-title" href="https://otricks.com/how-to-delete-mysql-binlog-files-if-you-dont-have-disk-space-left/">How to delete MySQL binlog files if you don&#8217;t have disk space left</a></li>
<li><a class="wp-block-latest-posts__post-title" href="https://otricks.com/responsiveness-in-reactive-programming/">Reactive Programming : Understanding Responsiveness</a></li>
</ul></div></div>
</div>
</div>
<p>The post <a rel="nofollow" href="https://otricks.com/steps-to-open-port-25-on-ec2-instance-amazon-web-service-aws/">Steps to open port 25 on EC2 instance &#8211; Amazon web service (AWS)</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to use webSocket/Socket.io inside Strapi content management system.</title>
		<link>https://otricks.com/how-to-use-websocket-socket-io-inside-strapi-content-management-system/</link>
		
		<dc:creator><![CDATA[Anjum Nawab]]></dc:creator>
		<pubDate>Wed, 29 Dec 2021 12:39:28 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Nodejs]]></category>
		<category><![CDATA[Server]]></category>
		<guid isPermaLink="false">https://otricks.com/?p=2369</guid>

					<description><![CDATA[<p>What is WebSocket? WebSocket is very useful pice of technology to communicate seamlessly from server to client, unlike HTTP it use full-duplex data transmission meaning, data&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://otricks.com/how-to-use-websocket-socket-io-inside-strapi-content-management-system/">How to use webSocket/Socket.io inside Strapi content management system.</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h3 class="wp-block-heading"><strong>What is WebSocket?</strong></h3>



<p>WebSocket is very useful pice of technology  to communicate seamlessly from server to client, unlike HTTP it use full-duplex data transmission meaning,  data can be transmitted in both directions on a signal carrier at the same time. To interact with webSocket we can use <a rel="noreferrer noopener" href="http://socket.io" target="_blank">socket.io</a> library which hides most of the stuff and provide clean API.</p>



<h3 class="wp-block-heading"><strong>What is strapi? </strong></h3>



<p>It&#8217;s headless content management system, if this headless makes no sense then think like <a href="https://wordpress.org/" target="_blank" rel="noreferrer noopener">wordpress</a> or <a href="https://www.joomla.org/">Joomla</a>  content management systems (cms) they comes with themes which user can install and see something in action, however in headless CMS there are no theme system, user needs to create their own theme for website or they can consume data on mobile apps.</p>



<p><a rel="noreferrer noopener" href="https://strapi.io/" target="_blank">Strapi</a> is open source nodejs based system, its based on <a rel="noreferrer noopener" href="https://koajs.com/" target="_blank">Koa.js.com</a> or follows same style of coding. Its comes with Rest API as well as <a rel="noreferrer noopener" href="https://graphql.org/" target="_blank">graphql</a> support too.</p>



<p>I don&#8217;t want to create chat-room example for this guide. May be We can create to booking system to send payload to Mars using <a rel="noreferrer noopener" href="https://www.spacex.com/vehicles/dragon/" target="_blank">space-x</a> shuttle service, where user can book a cargo in the space-x rocket once space is allocated from space-x&#8217;s team, the user will get notification via WebSocket about cargo space. </p>



<p>It&#8217;s going to be very long post, hence I will create it in multiple steps. I will be pushing code to Github in every step so do checkout all the steps of the code.</p>



<h3 class="wp-block-heading">I will try to implement following </h3>



<ul class="wp-block-list"><li>Create Angular application for frontend system (FE).</li><li>Create user login (FE)</li><li>Create protected route (FE)</li><li>Create Strapi application for backend system (BE).</li><li>Create sample API (BE).</li><li>Create dummy user (BE).</li><li>Start communication from Angular application to Strapi application.</li><li>Identify user and based on user send socket messages.</li></ul>



<p>Lets start building our frontend system first, I will call our fictional cargo booking company. space-XYZ .</p>



<p>Please click her to checkout frontend system.</p>



<p></p>
<p>The post <a rel="nofollow" href="https://otricks.com/how-to-use-websocket-socket-io-inside-strapi-content-management-system/">How to use webSocket/Socket.io inside Strapi content management system.</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to delete MySQL binlog files if you don&#8217;t have disk space left</title>
		<link>https://otricks.com/how-to-delete-mysql-binlog-files-if-you-dont-have-disk-space-left/</link>
		
		<dc:creator><![CDATA[Anjum Nawab]]></dc:creator>
		<pubDate>Thu, 23 Apr 2020 05:47:40 +0000</pubDate>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">https://otricks.com/?p=2351</guid>

					<description><![CDATA[<p>MySql does some really stupid stuff, often I feel like it&#8217;s no MY-SQL it SOMEONE-ELSE-SQL. Maybe it has some valid reasoning behind it, which I&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://otricks.com/how-to-delete-mysql-binlog-files-if-you-dont-have-disk-space-left/">How to delete MySQL binlog files if you don&#8217;t have disk space left</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>MySql does some really stupid stuff, often I feel like it&#8217;s no MY-SQL it SOMEONE-ELSE-SQL. Maybe it has some valid reasoning behind it, which I don&#8217;t know completely yet. One issue which often people encountered is  MySql binlog files.</p>



<p>These binlog files are very storage-intensive, most of the time for a small application each binlog file will be around 1.2GB.</p>



<p>Now imagine if you have 20GB disk-space it will eat up pretty much everything to the point where not a single kb is remaining for the server, if such thing happens, we even can&#8217;t run small commands like opening a file or editing a file etcetera.</p>



<p>As you can see in below image where It uses 100% of disk space 🙁  </p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="531" src="https://otricks.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-23-at-9.03.10-1024x531.png" alt="" class="wp-image-2352" srcset="https://otricks.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-23-at-9.03.10-1024x531.png 1024w, https://otricks.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-23-at-9.03.10-300x156.png 300w, https://otricks.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-23-at-9.03.10-768x398.png 768w, https://otricks.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-23-at-9.03.10.png 1072w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Some blog suggested that we can delete those files using <code>myql></code> in terminal, however if you don&#8217;t have any space left we can&#8217;t even run <code>sql</code> in terminal.</p>



<h2 class="wp-block-heading">The right way to remove binlog files.</h2>



<p>If you are a root user to the system you can do following things to get it deleted in proper way.</p>



<p>login to the system via ssh and run below command, it will make you root user.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">sudo -su</pre></div>



<p>Run <code>df -h</code> to check current disk space information, it will show you something like below. check <code>/dev/xvda1</code> section it consume all the space which I have it 🙁</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">Filesystem      Size  Used Avail Use% Mounted on
udev            236M     0  236M   0% /dev
tmpfs            49M  5.7M   44M  12% /run
/dev/xvda1       20G   20G     0 100% /
tmpfs           244M     0  244M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           244M     0  244M   0% /sys/fs/cgroup
/dev/loop0       92M   92M     0 100% /snap/core/8689
/dev/loop1       18M   18M     0 100% /snap/amazon-ssm-agent/1480
/dev/loop2       18M   18M     0 100% /snap/amazon-ssm-agent/1566
/dev/loop4       94M   94M     0 100% /snap/core/8935
tmpfs            49M     0   49M   0% /run/user/1000</pre></div>



<p>To get more information about your database usage you can run du -hs <code>/opt/bitnami/mysql/data</code> for me, it&#8217;s 16 bg, which is way too much for small application.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">16G	/opt/bitnami/mysql/data</pre></div>



<p>To check all the big files (in space allocation) run below command, it will show list of culprits </p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">du -hs /opt/bitnami/*/*/* |sort -rh | head -35</pre></div>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">1.1G	/opt/bitnami/mysql/data/binlog.000017
1.1G	/opt/bitnami/mysql/data/binlog.000016
1.1G	/opt/bitnami/mysql/data/binlog.000015
1.1G	/opt/bitnami/mysql/data/binlog.000014
1.1G	/opt/bitnami/mysql/data/binlog.000013
1.1G	/opt/bitnami/mysql/data/binlog.000012
1.1G	/opt/bitnami/mysql/data/binlog.000011
1.1G	/opt/bitnami/mysql/data/binlog.000010
1.1G	/opt/bitnami/mysql/data/binlog.000009
1.1G	/opt/bitnami/mysql/data/binlog.000008
1.1G	/opt/bitnami/mysql/data/binlog.000007
1.1G	/opt/bitnami/mysql/data/binlog.000006
1.1G	/opt/bitnami/mysql/data/binlog.000003
1.0G	/opt/bitnami/mysql/data/binlog.000018
569M	/opt/bitnami/mysql/data/binlog.000004</pre></div>



<p>At this point you even can&#8217;t open file via <code>nano etc.txt</code> or preform any other operation in the system as no space is left.</p>



<p>You can delete <code>binlog.000001</code> to get some space, run <code>rm binlog.000001</code> once it&#8217;s deleted  you will be able to run <code>nano</code> command.</p>



<p>Now open binlog.index file using  <code>nano binlog.index</code> and remove all the entries of binlog.0xxx from binlog.index file, once done save it and exit.</p>



<p>Run below to remove all fu(king binlog files at once, if you want you can remove <code>mysqld.log</code> files to as it might not be any use. </p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">rm binlog.00*</pre></div>



<p>After this if you run <code>df -h</code> you will get your space back. check <code>/dev/xvda1</code> section 🙂</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">Filesystem      Size  Used Avail Use% Mounted on
udev            236M     0  236M   0% /dev
tmpfs            49M  5.7M   44M  12% /run
/dev/xvda1       20G  4.4G   15G  23% /
tmpfs           244M     0  244M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           244M     0  244M   0% /sys/fs/cgroup
/dev/loop0       92M   92M     0 100% /snap/core/8689
/dev/loop1       18M   18M     0 100% /snap/amazon-ssm-agent/1480
/dev/loop2       18M   18M     0 100% /snap/amazon-ssm-agent/1566
/dev/loop4       94M   94M     0 100% /snap/core/8935
tmpfs            49M     0   49M   0% /run/user/1000</pre></div>



<p>Hope this will be helpful to someone.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p> I go beyond boundaries that trap me. Attachments and limitations in thinking are removed and I see people as actors playing roles sometimes negative and sometimes positive and scenes as passing phases, sometimes negative and sometimes positive. This experience translates into power in the consciousness as well as in words and actions.</p></blockquote>



<p>You may check other informative article  https://otricks.com/responsiveness-in-reactive-programming/ </p>
<p>The post <a rel="nofollow" href="https://otricks.com/how-to-delete-mysql-binlog-files-if-you-dont-have-disk-space-left/">How to delete MySQL binlog files if you don&#8217;t have disk space left</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Ideal setup for working with nodejs typescript in VS code?</title>
		<link>https://otricks.com/what-is-the-ideal-setup-for-working-with-nodejs-typescript-in-vs-code/</link>
		
		<dc:creator><![CDATA[Anjum Nawab]]></dc:creator>
		<pubDate>Fri, 20 Mar 2020 19:30:46 +0000</pubDate>
				<category><![CDATA[Nodejs]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">https://otricks.com/?p=2105</guid>

					<description><![CDATA[<p>I was a very big fan of nodemon for a long time. for those who don&#8217;t have any idea about nodemon, it&#8217;s file watcher that&#8217;s&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://otricks.com/what-is-the-ideal-setup-for-working-with-nodejs-typescript-in-vs-code/">Ideal setup for working with nodejs typescript in VS code?</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>I was a very big fan of <a href="https://www.npmjs.com/package/nodemon">nodemon</a> for a long time. for those who don&#8217;t have any idea about nodemon, it&#8217;s file watcher that&#8217;s looking for any change in any file and refreshes the project to see those changes. In nodejs ecosystem, its uses for debugging purpose which was very helpful. however on the other side its eat up all the system resource. </p>



<p>Now I have switched from nodemon to new amazing <a href="https://www.npmjs.com/package/ts-node-dev">ts-node-dev</a> as stated in npm site</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>It restarts target node process when any of required files changes (as standard <code>node-dev</code>) but shares <a href="https://github.com/Microsoft/TypeScript/">Typescript</a> compilation process between restarts. This significantly increases speed of restarting comparing to <code>node-dev -r ts-node/register ...</code>, <code>nodemon -x ts-node ...</code> variations because there is no need to instantiate <code>ts-node</code> compilation each time.</p></blockquote>



<p>I will show my vs code setup for typescript which auto recompile and uses ts-node-dev package for any file change event.</p>



<h2 class="wp-block-heading">Setup vs code for typescript </h2>



<p>Create a new project in your computer</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">mkdir dummyProject
cd dummyProject</pre></div>



<p>I will be using npm as my package manager, let&#8217;s create a new package with default settings with below command </p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">npm init -y</pre></div>



<p>It will generate a new file as a package.json </p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="json" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">{
  "name": "dummyProject",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}</pre></div>



<p>Add typescript,  ts-node-dev and create new src folder with index.ts file inside.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">npm install typescript ts-node-dev --save-dev
</pre></div>



<p>Open package.json file and add below script inside the scripts block.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="json" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">"dev": "ts-node-dev --respawn --transpileOnly src/index.ts"
"dev:debug": "ts-node-dev --inspect=4321 --respawn --transpileOnly src/index.ts"</pre></div>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="json" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">{
  "name": "dummyProject",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "ts-node-dev --respawn --transpileOnly src/index.ts",
    "dev:debug": "ts-node-dev --inspect=4321 --respawn --transpileOnly src/index.ts"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}
</pre></div>



<h2 class="wp-block-heading">Visual studio code debugging</h2>



<p>Inside visual studio code, we can add a breakpoint in the typescript code which can stop at certain points. Inside your root directory of the current project.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">mkdir .vscode
cd .vscode
touch launch.json</pre></div>



<p>Paste the following into your <code>launch.json</code> which we have created the previous step.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="json" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "attach",
      "name": "Attach to dev:debug",
      "protocol": "inspector",
      "port": 4321,
      "restart": true,
      "cwd": "${workspaceRoot}"
    }
  ]
}</pre></div>



<p>Now do <code>npm run dev:debug</code> first in vs code terminal. once its&#8217; started then click on the debug button from the left  menu in VS code. it will open debugger panel something below.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="615" src="https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-20-at-23.22.05-1024x615.png" alt="sample vs code with debugger step" class="wp-image-2117" srcset="https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-20-at-23.22.05-1024x615.png 1024w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-20-at-23.22.05-300x180.png 300w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-20-at-23.22.05-768x461.png 768w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-20-at-23.22.05-1536x923.png 1536w, https://otricks.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-20-at-23.22.05-2048x1231.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Check out other tips such as <a href="https://otricks.com/how-to-secure-your-ubuntu-server-from-brute-force-attacks/">How to secure ubuntu server</a> </p>
<p>The post <a rel="nofollow" href="https://otricks.com/what-is-the-ideal-setup-for-working-with-nodejs-typescript-in-vs-code/">Ideal setup for working with nodejs typescript in VS code?</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to secure your Ubuntu server from brute-force attacks?.</title>
		<link>https://otricks.com/how-to-secure-your-ubuntu-server-from-brute-force-attacks/</link>
		
		<dc:creator><![CDATA[Anjum Nawab]]></dc:creator>
		<pubDate>Tue, 10 Mar 2020 11:52:55 +0000</pubDate>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<guid isPermaLink="false">https://otricks.com/?p=2057</guid>

					<description><![CDATA[<p>Nowadays more and more people and organizations are going on the cloud for their applications, and its very common practice to have a server on&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://otricks.com/how-to-secure-your-ubuntu-server-from-brute-force-attacks/">How to secure your Ubuntu server from brute-force attacks?.</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Nowadays more and more people and organizations are going on the cloud for their applications, and its very common practice to have a server on the cloud. As more people are using cloud solutions so do more attackers are after them.</p>



<p>According to Ubuntu data, there are around at least 20 million users are using Ubuntu and that&#8217;s a very big number. It would be a gold mine for attackers who keep trying to get access to your server using a brute-force attack, for those who don&#8217;t know what the hack is brute-force attack?. its an attempt to crack username and password, using trial and error approach with the hope to get it correct for multiple time, if you keep your password or username very generic or easy to guess they might get into your system.</p>



<p>It&#8217;s a very old attack method, however, it&#8217;s still very effective and popular within the hacker community.    You can read more about brute-force attack here.<a rel="noreferrer noopener" target="_blank" href="https://en.wikipedia.org/wiki/Brute-force_attack">https://en.wikipedia.org/wiki/Brute-force_attack</a></p>



<p>It&#8217;s always a better idea to secure your system/service/server from such wicked people. Let&#8217;s get it done.</p>



<p>I will be using my  Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-88-generic x86_64) machine.</p>



<p>Update your system first running below commands in the terminal, my assumption is you are already logged in with Root access using SSH.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><div style="position:absolute;top:-20px;right:0px;cursor:pointer" class="copy-simple-code-block"><svg aria-hidden="true" role="img" focusable="false" class="dashicon dashicons-admin-page" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20"><path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"></path></svg></div><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="true">apt-get update
apt-get upgrade</pre></div>



<p>After a system update add Fail2ban, which is an invasion blocking software framework that protects servers from brute-force attacks, it&#8217;s written in the Python.</p>



<p>Fail2Ban scans log files like /var/log/auth.log and bans IP addresses conducting too many failed login attempts. It does this by updating system firewall rules to reject new connections from those IP addresses, for a configurable amount of time. </p>



<p>Fail2Ban comes out-of-the-box ready to read many standard log files, such as those for sshd and Apache, and is easily configured to read any log file of your choosing, for any error you wish.</p>



<p>Though Fail2Ban is able to reduce the rate of incorrect authentication attempts, it cannot eliminate the risk presented by weak authentication. Set up services to use only two factor, or public/private authentication mechanisms if you really want to protect services.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><div style="position:absolute;top:-20px;right:0px;cursor:pointer" class="copy-simple-code-block"><svg aria-hidden="true" role="img" focusable="false" class="dashicon dashicons-admin-page" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20"><path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"></path></svg></div><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="true">
apt-get install fail2ban</pre></div>



<p>Copy the configuration file and do changes </p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><div style="position:absolute;top:-20px;right:0px;cursor:pointer" class="copy-simple-code-block"><svg aria-hidden="true" role="img" focusable="false" class="dashicon dashicons-admin-page" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20"><path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"></path></svg></div><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="true">sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local</pre></div>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><div style="position:absolute;top:-20px;right:0px;cursor:pointer" class="copy-simple-code-block"><svg aria-hidden="true" role="img" focusable="false" class="dashicon dashicons-admin-page" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20"><path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"></path></svg></div><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="true">
sudo nano /etc/fail2ban/jail.local</pre></div>



<p></p>



<p>Change the ban time from 600 (10 minutes) to 604800 (7 days) is guess this would be more than enough to have peaceful nights 🙂</p>



<p>Nest step is to install logwatch is the tool the aggregate all system logs and make meaningful decisions. </p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><div style="position:absolute;top:-20px;right:0px;cursor:pointer" class="copy-simple-code-block"><svg aria-hidden="true" role="img" focusable="false" class="dashicon dashicons-admin-page" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20"><path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"></path></svg></div><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="true">
apt-get install logwatch</pre></div>



<p>Logwatch can be configurated to trigger a daily email of your logs.</p>



<p></p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><div style="position:absolute;top:-20px;right:0px;cursor:pointer" class="copy-simple-code-block"><svg aria-hidden="true" role="img" focusable="false" class="dashicon dashicons-admin-page" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20"><path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"></path></svg></div><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="true">nano /etc/cron.daily/00logwatch</pre></div>



<p>Add below line at the bottom of the cron job file and replace the example email with your own address. </p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><div style="position:absolute;top:-20px;right:0px;cursor:pointer" class="copy-simple-code-block"><svg aria-hidden="true" role="img" focusable="false" class="dashicon dashicons-admin-page" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 20 20"><path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"></path></svg></div><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="sh" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="true">/usr/sbin/logwatch --output mail --mailto mail@example.com --detail high</pre></div>
<p>The post <a rel="nofollow" href="https://otricks.com/how-to-secure-your-ubuntu-server-from-brute-force-attacks/">How to secure your Ubuntu server from brute-force attacks?.</a> appeared first on <a rel="nofollow" href="https://otricks.com">Otricks.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
