<?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/tag/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>Thu, 23 Apr 2020 06:16:14 +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>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 fetchpriority="high" 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>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>
