{"id":187,"date":"2020-01-31T21:43:27","date_gmt":"2020-01-31T20:43:27","guid":{"rendered":"https:\/\/codedoneright.eu\/?page_id=187"},"modified":"2021-03-02T06:16:44","modified_gmt":"2021-03-02T05:16:44","slug":"basic-security-for-our-server","status":"publish","type":"page","link":"https:\/\/codedoneright.eu\/?page_id=187","title":{"rendered":"Basic security"},"content":{"rendered":"\n<p>Every server accessible from the internet is going to be a target of an attack at some point, this is a fact and there is no exception. You will have proof of that in your logs. Fortunately, unless your server gains popularity and attracts a real hacker, majority of those attacks are going to be either bots or script kiddies trying out the combination of known password pairs like admin\/admin. Still, you need to protect yourself from them.<\/p>\n\n\n\n<p>The most newbie friendly solution is to install packages that will<\/p>\n\n\n\n<ul><li>Block access to ports that should not be accessed<\/li><li>Ban bots that are using known password pairs to gain access (brute force attacks)<\/li><li>Run an antivirus scan<\/li><li>Run automated update notification script<\/li><\/ul>\n\n\n\n<p>Even though I will instruct you how to seetup all this, I still advise to pay attention to system logs. You need to know what is happening to your server. What one man wrote, the other can hack. From time to time you hear about password leaks or break-ins to major players like Dropbox or iCloud, a home server will never be more secure than companies using first rate security solutions. Security measures I will talk about in a moment should be enough for your home server. <\/p>\n\n\n\n<div style=\"height:76px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">UFW \u2013 security 101<\/h2>\n\n\n\n<p>UFW stands for Uncomplicated Firewall. This is the first security measure that you need to take. Its purpose is to block access to ports that you do not need to have open. <\/p>\n\n\n\n<p>Every connection uses one port from the pool of  65535 ports. And UFW is going to block those in case you run a service listening for a connection on one of those ports and you do not want it to be accessible from outside. On the other hand, you need to have certain ports open in order for your services to be accessible from the outside.<\/p>\n\n\n\n<p>For example, you will not be able to access a website on your server without opening port 80 for http:\/\/ There is a <a href=\"https:\/\/en.wikipedia.org\/wiki\/List_of_TCP_and_UDP_port_numbers\">list of standard ports for services<\/a> \u2013 22 for SSH connection, 80 for websites, 993 for email etc., and in theory we could change some of those in order to secure access to our server, but in practice <a href=\"https:\/\/www.ipfingerprints.com\/portscan.php\">ports can be mapped<\/a> and the attacker can discover which ports are open on our server and that, in turn, nullifies the whole point of changing ports. So let us just block everything that does not need to be open and leave defaults as they are. <\/p>\n\n\n\n<p>I encourage you to read more about the topic of ports and why some require an encrypted connection and some are freely open but for now just follow me.<\/p>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">UFW installation<\/h4>\n\n\n\n<p>In order to install UFW run the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install ufw<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Before you proceed!<\/h4>\n\n\n\n<p><br><strong>CAUTION <\/strong>do not enable the firewall before opening port 22. If you block port 22, you will not be able to connect to your server and you will have to boot your pi with external monitor to open said por<\/p>\n\n\n\n<p><br><strong>CAUTION! <\/strong>delete the default user <em>pi<\/em> before opening your server to the internet. Logging in with valid credentials is <strong>not <\/strong>an attack, it is system administration malpractice. Leaving the <em>pi<\/em> user with sudo privileges allows anyone to remotely log in and do as he pleases, your data will get stolen, your server will get broken and your time setting everything up will be wasted. Find out how to delete user <em>pi<\/em> in the previous part of the tutorial <a href=\"https:\/\/codedoneright.eu\/?page_id=78\">here<\/a>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">UFW configuration<\/h4>\n\n\n\n<p>UFW is not enabled after installation and we need to manually do so, but before we do that we need to open at least port 22 for SSH connection, and while at it, we might as well enable all ports that we are going to use.<\/p>\n\n\n\n<p> First of all we need to set up a few exceptions to open some of ports to our server. Run the following commands<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw allow 20\nsudo ufw allow 21\nsudo ufw allow 22\nsudo ufw allow 25\nsudo ufw allow 80\nsudo ufw allow 143\nsudo ufw allow 443\nsudo ufw allow 465\nsudo ufw allow 587\nsudo ufw allow 993<\/code><\/pre>\n\n\n\n<p>Check out why we opened those specific ports on <a href=\"https:\/\/en.wikipedia.org\/wiki\/List_of_TCP_and_UDP_port_numbers\">Wikipedia<\/a><\/p>\n\n\n\n<p>You will get a prompt after adding any rule, should a rule be already in place you will get <em>skipping rule<\/em> prompt. Rules will be applied to both IPv4 and IPv6.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">FTP ports<\/h5>\n\n\n\n<p>On top of that we need to have a few ports for FTP passive access. You can open only one, but should you install a package listening on that specific port, your FTP access will be blocked. It is just common sense to open a small range. UFW allows for specifying a range instead of just one port in a rule and we need to decide what ports we are going to use for our FTP access. Ports go from 0 to 65535. Pick ten, any ten ports. Now run the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw allow $PASSIVE_MIN:$PASSIVE_MAX\/tcp<\/code><\/pre>\n\n\n\n<p>Substitute <em>$PASSIVE_MIN<\/em> and <em>$PASSIVE_MAX<\/em> with the range you have chosen for FTP. It does not have to be ten ports, it can be two, five or thirty. Just do not make it one, and ten is a such a nice round number. If you have chosen range from 667 to 700 the command would look as follows<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw allow 667:700\/tcp<\/code><\/pre>\n\n\n\n<p>When adding a range you have to specify if this should open TCP or UDP ports. We want TCP.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Enabling UFW<\/h4>\n\n\n\n<p>Now that we have everything in place, we can finally enable UFW by running the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw enable<\/code><\/pre>\n\n\n\n<p>Idiot-proofing measure asks you if you are sure that you want to enable UFW as you may lose access, but since we opened port 22 we are ok with starting the UFW service. Answer <em>yes<\/em><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Checking rules in place and removing them<\/h4>\n\n\n\n<p>If you want to check what rules are in place run the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw status numbered<\/code><\/pre>\n\n\n\n<p>Parameter <em>numbered <\/em>shows us an additional column with numbers next to rules that makes removing them easy. We can do that by running the following command <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw delete x<\/code><\/pre>\n\n\n\n<p>Substitute <em>x<\/em> with the number of a rule you want to remove. Bear in mind that the list shifts after deleting one of them. Meaning that if you want to delete three consecutive rules then you have to delete the same rule three times, as for example rule 7 becomes rule 6 after you delete the initial rule 6. Just allow a few random ports, print out the rule list, delete one of them and print out the rule list again. You will see for yourself.<\/p>\n\n\n\n<p>You might not realize, but with Raspbian you get a firewall security with the system by default in the form of IPTABLES. Using it without UFW is a different story. UFW is actually a front-end for IPTABLES. Think of it as hiring a crew to build your house instead of having to set up a tent every time you want to get some sleep. That is it for UFW installation and configuration. Once enabled is will boot up with the system.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Restoring default rules<\/h4>\n\n\n\n<p>In case you made a big mess of rules you can simply revert to defaults by running the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw reset<\/code><\/pre>\n\n\n\n<p>Before you do that it is advised to deactivate UFW as your SSH connection might get dropped. Run the following to disable UFW<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw disable<\/code><\/pre>\n\n\n\n<p>After you reset all rules simly add those that you actually need and enable UFW again.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Running IPv4 server only<\/h4>\n\n\n\n<p>If you have only IPv4 address you can skip adding IPv6 rules by modifying UFW config located here<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/etc\/default\/ufw<\/code><\/pre>\n\n\n\n<p>and changing the following rule to <em>no<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>IPV6=yes<\/code><\/pre>\n\n\n\n<div style=\"height:76px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">SSHGuard \u2013 security by banning offenders<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" src=\"https:\/\/www.sshguard.net\/media\/images\/after.png\" alt=\"SSHGuard security\"\/><figcaption>SSHGuard blocks brute-force attacks<\/figcaption><\/figure><\/div>\n\n\n\n<p>This security package monitors your logs for an unauthorized access, validates the threat level and when the level reaches certain threshold it jails the attacker for a period of time. In layman terms \u2013 put incorrect login credentials too many times and you are banned for a period of time, any further login tries within the jail period will only extend it exponentially. Simple and effective.<\/p>\n\n\n\n<p><strong>CAUTION <\/strong>you are not exempt. If you forget the user name or your password  and you will try logging in with incorrect credentials you will get banned as well. Mind the login!<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Installing SSHGuard<\/h4>\n\n\n\n<p>Keeping the above in mind let us install SSHGuard with the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install sshguard<\/code><\/pre>\n\n\n\n<p>Contrary to UFW, security is enabled right after installation and daemon is loaded after every reboot out of the box. Default setting jails an IP for 3 minutes after 3 consecutive incorrect logins within a short period of time. More information about SSHGuard can be found <a href=\"http:\/\/sshguard.net\">here<\/a>. <\/p>\n\n\n\n<p>SSHGuard, just like UFW, uses IPTABLES firewall and is just a front-end for the service. We could get by without both UFW and SSHGuard but that is a difference between running a few simple commands and writing a complicated scripts that need to be ran after every reboot. The hassle is just not worth it and you should just use those two wonderful tools.<\/p>\n\n\n\n<p>In case you are facing problems with SSHGuard you can try the <em>fail2ban<\/em> alternative. This is a more popular solution, but I found that it conflicted with my mail setup, so I am using SSHGuard. The functionality is the same. If you run into any trouble with one then try using the other.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Whitelisting your local IP<\/h4>\n\n\n\n<p>If you do not want to lock yourself out of your server, you might want to whitelist your local IP address of the client you will use to tinker with the server.<\/p>\n\n\n\n<p>Run the following<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/sshguard\/whitelist<\/code><\/pre>\n\n\n\n<p>And at the bottom of the file add your local IP address. One IP per line<\/p>\n\n\n\n<div style=\"height:76px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">ClamAV \u2013 security with  antivirus<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" src=\"https:\/\/www.clamav.net\/assets\/clamav-trademark.png\" alt=\"\"\/><figcaption>ClamAV\u00ae is an open source antivirus engine for detecting trojans, viruses, malware &amp; other malicious threats<\/figcaption><\/figure><\/div>\n\n\n\n<p>It is very unlikely that you will catch a virus on your server but it may happen. Better safe than sorry. A good and a free choice is ClamAV which we will configure to run daily at a certain time. It will scan your system and get rid of infected files should it find any.<\/p>\n\n\n\n<p><strong>CAUTION<\/strong> from my experience with Pi Zero, is just too weak to handle ClamAV and it simply gives up at some point during the scan. If you think you know what is going on or managed to do it with Pi Zero then leave a comment.<\/p>\n\n\n\n<p>Install ClamAV with the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install clamav<\/code><\/pre>\n\n\n\n<p>Out of the box ClamAV updates its database automatically and you do not have to worry about it. Scanning on the other hand has to be taken care of manually. Real-time protection is in form of warnings. You will not be stopped from accessing an infected file. You can read more about ClamAV and its configuration <a href=\"http:\/\/www.clamav.net\">here<\/a>.<\/p>\n\n\n\n<p><strong>CAUTION <\/strong>clamav will perform an update and a scan after installation. This will consume resources for quite a while, depending on the number of files you have on SD and on the Pi you are running. Use the command <em>htop <\/em>to confirm this, you should see a screen similar to below image<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"677\" height=\"131\" src=\"https:\/\/codedoneright.eu\/wp-content\/uploads\/clamav_scan.png\" alt=\"clamav security antivirus scan\" class=\"wp-image-451\"\/><figcaption>ClamAV consuming Raspberry Pi Zero resources<\/figcaption><\/figure><\/div>\n\n\n\n<p>It took about 20 minutes on a freshly installed Raspbian on a Pi Zero W with SanDisk Ultra UHS-I SD card. The time needed for scan will vary depending on the Pi you are running, the speed of your SD card and the number of files on it.<\/p>\n\n\n\n<p>Give it time to complete before proceeding further.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Setting up a daily scan<\/h4>\n\n\n\n<p>In order to set up a daily scan we need to make a bash script. Since we will have the script running by itself via Cron, an automatic task schedule package, it is a good idea to set it up somewhere else than our home directory so it does not get in the way. And while we are at it we can set up a directory for custom log files as well.<\/p>\n\n\n\n<p>Choose a place for scripts and logs now. Is is a good idea to put our ClamAV logs in a subfolder as well. A good choice is the <em>\/var\/<\/em> folder, as its name suggests, it is for various files. Again, this can be any place you want, but make it easily accessible so you do not have to dig through folders to find them.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Creating custom folders for logs and scripts<\/h5>\n\n\n\n<p>In order to create those three custom folders run the following commands<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkdir \/var\/zzz_log\nsudo mkdir \/var\/zzz_log\/clamav\nsudo mkdir \/var\/zzz_script<\/code><\/pre>\n\n\n\n<p>Adding a <em>zzz_<\/em> prefix will send them to the bottom of the folder list and make them easier to find. If you want, you can call them <em>fluffybunny1<\/em> and <em>iloverainbow <\/em>if you wish.<\/p>\n\n\n\n<p>Now lets change the owners of said folders, run the following code to make those folders assigned to your administrative user, that you have chosen in the <a href=\"https:\/\/codedoneright.eu\/?page_id=78\">installation part<\/a> of the tutorial<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chown $USER:$USER -R \/var\/zzz_log\nsudo chown $USER:$USER -R \/var\/zzz_log\/clamav\nsudo chown $USER:$USER -R \/var\/zzz_script<\/code><\/pre>\n\n\n\n<p>Folders should have the correct permissions assigned to them, but in case they do not, we need to set them up with the following code<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chmod 755 -R \/var\/zzz_log\nsudo chmod 755 -R \/var\/zzz_log\/clamav\nsudo chmod 755 -R \/var\/zzz_script<\/code><\/pre>\n\n\n\n<p>This will allow the <em>$USER<\/em> to read, write and execute anything inside those folders while <em>$USER<\/em>&#8216;s group and other accounts will be able to read an execute files inside without the write ability. You can read about file permissions <a href=\"https:\/\/debian-handbook.info\/browse\/stable\/sect.rights-management.html\">here<\/a>. Do get yourself acquainted with managing rights as this is a very important part of working with Linux. In the infancy of your dealings with system administration you will often run into hurdles if you do not know how to manage permissions.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Creating the daily script itself<\/h5>\n\n\n\n<p>Now we need to make the script itself. The below script is almost a direct copy of Habilis&#8217; script <a href=\"https:\/\/habilisbest.com\/raspberrypi-secure-personal-server-step-3-hardening-security\">here<\/a>. It is a nice and useful peace of code and I am not the one to reinvent the wheel.<\/p>\n\n\n\n<p>In order to create a file and edit it run the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nano \/var\/zzz_script\/daily_scan.sh<\/code><\/pre>\n\n\n\n<p>Inside of it paste the following code<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\nLOG=\/var\/zzz_log\/clamav_scan.log\nMYLOG=\/var\/zzz_log\/clamav_mylog.log\n\nFIND=\"$(which find)\"\nDATE=\"$(which date)\"\nGREP=\"$(which grep)\"\n\nTIMESTAMP=`$DATE '+%Y-%m-%d %H:%M'`\n\nif &#91;&#91; ! -e \/tmp\/virus ]]; then\n  mkdir \/tmp\/virus\nfi\n\ncheck_scan () {\nif &#91; `tail -n 12 ${LOG} | $GREP Infected | $GREP -v 0 | wc -l` != 0 ]\nthen\necho \"$TIMESTAMP VIRUS DETECTED\"\n1>> $MYLOG\necho \"`tail -n 50 ${LOG}`\" 1>> $MYLOG\necho \"#####################################\"\n1>> $MYLOG\nelse\necho \"$TIMESTAMP - scan has been performed as expected\" 1>> $MYLOG\nfi\n}\n\nclamscan -r \/ --move=\/tmp\/virus --max-filesize=600M --max-scansize=600M --exclude-dir=\/sys\/ --quiet --infected --log=${LOG}\ncheck_scan<\/code><\/pre>\n\n\n\n<p>Make sure the script is executable with the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chmod a+x \/var\/zzz_script\/daily_scan.sh<\/code><\/pre>\n\n\n\n<p>Read more about <a href=\"https:\/\/codedoneright.eu\/?page_id=414\">scripting in bash<\/a> if you want to fully understand the script. With time you will have to anyways, might as well start now. <\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p><strong>CAUTION<\/strong> if you are running a NAS, or you have large folders with files like video etc. then you need to include path to such folders by adding additional arguments<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>--exclude-dir=\/path\/to\/folder\/<\/code><\/pre>\n\n\n\n<p>Just put it after the first one in the script. Otherwise your antivirus scan will scan those folders as well and will unnecessarily throttle your system!<\/p>\n\n\n\n<p>You can do that at any point in time, just remember about it after adding a 1TB NAS with video files. <\/p>\n<\/div><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">What does the script even mean?<\/h4>\n\n\n\n<p>The script works out of the box, but if you are curious what those lines do here is the breakdown<\/p>\n\n\n\n<ul><li><em>#!\/bin\/bash<\/em> \u2013 this is how any script starts, with a shebang and path to shell it is going to be executed in<\/li><li><em>LOG<\/em> and <em>MYLOG<\/em> lines define places where we will store ClamAV logs<\/li><li><em>FIND, DATE, GREP<\/em> and <em>TIMESTAMP <\/em>set up some variables for the script to use later, they are pretty self explanatory, if not brush up on <a href=\"https:\/\/codedoneright.eu\/?page_id=74\">basic commands<\/a> we are dealing with linux so there is no hand-holding here<\/li><li>First <em>if module<\/em> checks if there is a <em>\/temp\/virus<\/em> folder present, if not \u2013 it creates it<\/li><li>check_scan () is a custom procedure for checking ClamAV <em>$LOG<\/em> and if a virus has been detected it writes to <em>$MYLOG<\/em> saying so. You should check the main log for more information in such a case. It is set up this way so you do not have to scrub many logs and you can just take a look at <em>$MYLOG<\/em> to see if everything is OK, we will also add this information later to our SSH welcome screen. You will know if you need to check out the log right after logging to your server<\/li><li>clamscan command is what actually performs the scan itself and takes care of any virae it finds. Type <em>clamscan &#8211;help<\/em> in CLI for more in-depth information regarding attributes used, there is no point in retyping the MAN page here<\/li><\/ul>\n\n\n\n<p>Make sure the script executable with the <em>ls -l <\/em>command. If not, see above part about <em>chmod <\/em>and <em>chown<\/em><\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Scheduling the task<\/h5>\n\n\n\n<p>Since we want to automate the scan we need to use cron, a tool for scheduling tasks. It is built into the system so we do not have to install it, we just need to set it up<\/p>\n\n\n\n<p>Run the follownig code <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo crontab -e<\/code><\/pre>\n\n\n\n<p>At the bottom of the file add the following line<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>0 5 * * * \/var\/zzz_script\/daily_scan.sh<\/code><\/pre>\n\n\n\n<p>This makes the script, and by extension the scan, run at 5am every day. You can set up a different time of day or make it run every 7 hours for example, but once a day should be enough for our peace of mind. Take a look at the crontab file where you added the task, it tells you how to schedule tasks for different hours and\/or time intervals.<\/p>\n\n\n\n<p><strong>CAUTION <\/strong>do not set up many tasks for the same time as it will slow down your server to a crawl. Your Pi might start to overheat and when it reaches 85 degrees Celsius it will throttle the CPU to cool itself and in turn all operations will slow down. Set up tasks for different full hours and you will be ok.<\/p>\n\n\n\n<div style=\"height:76px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Security is paramount! With UFW and SSH Guard in place we are done with basic security, server should be protected from most common threats by now and we can move on to installing actual services that our server will provide. This is the absolute and bare minimum that we need. Not using UFW and SSH Guard is, as stated before, plain malpractice. Did you remove the user <em>pi<\/em> as well? If not go <a href=\"https:\/\/codedoneright.eu\/?page_id=78\">HERE <\/a>right now and do it! With the addition of anti-virus scan we should have a peace of mind. Up next \u2013 setting up an FTP server!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every server accessible from the internet is going to be a target of an attack at some point, this is a fact and there is no exception. You will have proof of that in your logs. Fortunately, unless your server&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"parent":71,"menu_order":15,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Basic security \u2013 do not get hacked &#8212; Code Done Right!<\/title>\n<meta name=\"description\" content=\"Learn the basics of security on your home server, block port access, block brute-force attacks and set up a daily antivirus scan\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codedoneright.eu\/?page_id=187\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Basic security \u2013 do not get hacked &#8212; Code Done Right!\" \/>\n<meta name=\"twitter:description\" content=\"Learn the basics of security on your home server, block port access, block brute-force attacks and set up a daily antivirus scan\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.sshguard.net\/media\/images\/after.png\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"15 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/codedoneright.eu\/?page_id=187\",\"url\":\"https:\/\/codedoneright.eu\/?page_id=187\",\"name\":\"Basic security \u2013 do not get hacked &#8212; Code Done Right!\",\"isPartOf\":{\"@id\":\"https:\/\/codedoneright.eu\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/codedoneright.eu\/?page_id=187#primaryimage\"},\"image\":{\"@id\":\"https:\/\/codedoneright.eu\/?page_id=187#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.sshguard.net\/media\/images\/after.png\",\"datePublished\":\"2020-01-31T20:43:27+00:00\",\"dateModified\":\"2021-03-02T05:16:44+00:00\",\"description\":\"Learn the basics of security on your home server, block port access, block brute-force attacks and set up a daily antivirus scan\",\"breadcrumb\":{\"@id\":\"https:\/\/codedoneright.eu\/?page_id=187#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/codedoneright.eu\/?page_id=187\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codedoneright.eu\/?page_id=187#primaryimage\",\"url\":\"https:\/\/www.sshguard.net\/media\/images\/after.png\",\"contentUrl\":\"https:\/\/www.sshguard.net\/media\/images\/after.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/codedoneright.eu\/?page_id=187#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/codedoneright.eu\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Raspberry Pi server\",\"item\":\"https:\/\/codedoneright.eu\/?page_id=71\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Basic security\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/codedoneright.eu\/#website\",\"url\":\"https:\/\/codedoneright.eu\/\",\"name\":\"Code Done Right!\",\"description\":\"Raspberry Pi server guides\",\"publisher\":{\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/codedoneright.eu\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568\",\"name\":\"CodeDoneRight\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png\",\"contentUrl\":\"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png\",\"width\":120,\"height\":120,\"caption\":\"CodeDoneRight\"},\"logo\":{\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/codedoneright.eu\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Basic security \u2013 do not get hacked &#8212; Code Done Right!","description":"Learn the basics of security on your home server, block port access, block brute-force attacks and set up a daily antivirus scan","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codedoneright.eu\/?page_id=187","twitter_card":"summary_large_image","twitter_title":"Basic security \u2013 do not get hacked &#8212; Code Done Right!","twitter_description":"Learn the basics of security on your home server, block port access, block brute-force attacks and set up a daily antivirus scan","twitter_image":"https:\/\/www.sshguard.net\/media\/images\/after.png","twitter_misc":{"Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/codedoneright.eu\/?page_id=187","url":"https:\/\/codedoneright.eu\/?page_id=187","name":"Basic security \u2013 do not get hacked &#8212; Code Done Right!","isPartOf":{"@id":"https:\/\/codedoneright.eu\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codedoneright.eu\/?page_id=187#primaryimage"},"image":{"@id":"https:\/\/codedoneright.eu\/?page_id=187#primaryimage"},"thumbnailUrl":"https:\/\/www.sshguard.net\/media\/images\/after.png","datePublished":"2020-01-31T20:43:27+00:00","dateModified":"2021-03-02T05:16:44+00:00","description":"Learn the basics of security on your home server, block port access, block brute-force attacks and set up a daily antivirus scan","breadcrumb":{"@id":"https:\/\/codedoneright.eu\/?page_id=187#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codedoneright.eu\/?page_id=187"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codedoneright.eu\/?page_id=187#primaryimage","url":"https:\/\/www.sshguard.net\/media\/images\/after.png","contentUrl":"https:\/\/www.sshguard.net\/media\/images\/after.png"},{"@type":"BreadcrumbList","@id":"https:\/\/codedoneright.eu\/?page_id=187#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codedoneright.eu\/"},{"@type":"ListItem","position":2,"name":"Raspberry Pi server","item":"https:\/\/codedoneright.eu\/?page_id=71"},{"@type":"ListItem","position":3,"name":"Basic security"}]},{"@type":"WebSite","@id":"https:\/\/codedoneright.eu\/#website","url":"https:\/\/codedoneright.eu\/","name":"Code Done Right!","description":"Raspberry Pi server guides","publisher":{"@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codedoneright.eu\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568","name":"CodeDoneRight","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/","url":"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png","contentUrl":"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png","width":120,"height":120,"caption":"CodeDoneRight"},"logo":{"@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/codedoneright.eu"]}]}},"_links":{"self":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/187"}],"collection":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=187"}],"version-history":[{"count":51,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/187\/revisions"}],"predecessor-version":[{"id":1675,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/187\/revisions\/1675"}],"up":[{"embeddable":true,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/71"}],"wp:attachment":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}