Enable vim cut paste Debian 9

 

Enable vim cut paste Debian 9 with preferable global solution for all users, which loads the default options and then adds or overwrites the defaults with the personal settings.

Luckily there is an option for that in Debian: The /etc/vim/vimrc.local will be loaded after the /etc/vim/vimrc. So you can create this file and load defaults, preventing them from being loaded again (at the end) and then add your personal options:

Please create the following file: /etc/vim/vimrc.local and paste the code

#nano /etc/vim/vimrc.local
" This file loads the default vim options at the beginning and prevents
" that they are being loaded again later. All other options that will be set,
" are added, or overwrite the default settings. Add as many options as you
" whish at the end of this file.

" Load the defaults
source $VIMRUNTIME/defaults.vim

" Prevent the defaults from being loaded again later, if the user doesn't
" have a local vimrc (~/.vimrc)
let skip_defaults_vim = 1
" Set more options (overwrites settings from /usr/share/vim/vim80/defaults.vim)
" Add as many options as you whish

" Set the mouse mode to 'r'
if has('mouse')
set mouse=r
endif

" Toggle paste/nopaste automatically when copy/paste with right click in insert mode:
let &t_SI .= "\<Esc>[?2004h"
let &t_EI .= "\<Esc>[?2004l"

inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()

function! XTermPasteBegin()
set pastetoggle=<Esc>[201~
set paste
return ""
endfunction

Source: https://unix.stackexchange.com/questions/318824/vim-cutpaste-not-working-in-stretch-debian-9

Setup Fail2ban on Debian 9

Update the system

#apt update && apt upgrade -y

Modify SSH port (Optional), Change port number 22, for example to 3000

#sed -i "s/#Port 22/Port 3000/g" /etc/ssh/sshd_config
#systemctl restart sshd.service

Debian 8: open the /etc/ssh/sshd_config, change port 22 to 3000

#vim /etc/ssh/sshd_config

Update IPTables rules, change SSH port on /etc/iptables.up.rules config

#/usr/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#/usr/sbin/iptables -A INPUT -p tcp --dport 22 -j DROP
#/usr/sbin/iptables -A INPUT -p tcp --dport 3000 -j ACCEPT

Save the updated IPTables rules to a file for persistence purposes:

#/usr/sbin/iptables-save > /etc/iptables.up.rules
#touch /etc/network/if-pre-up.d/iptables
#chmod +x /etc/network/if-pre-up.d/iptables
#echo '#!/bin/sh' >> /etc/network/if-pre-up.d/iptables
#echo '/sbin/iptables-restore < /etc/iptables.up.rules' >> /etc/network/if-pre-up.d/iptables

Debian 10 IPtables persistent make your iptables rules persistent install iptables-persistent package:

#apt-get install iptables-persistent

Debian 10 IPtables Save to update iptables with new rules use IPtables Save

#iptables-save > /etc/iptables/rules.v4
#ip6tables-save > /etc/iptables/rules.v6

If UFW please follow command belows;

#sudo ufw allow 3000/tcp
#sudo ufw status
Status: active
To                         Action      From
--                         ------      ----
3000/tcp                     ALLOW       Anywhere
3000/tcp (v6)                ALLOW       Anywhere (v6)

Removing UFW port 22 Firewall Rule by Checking UFW status with the parameter numbered. This allows you to select a rule by entry number.

#sudo ufw status numbered
Status: active
To Action From
-- ------ ----
[ 1] Apache DENY IN Anywhere
[ 2] 22 ALLOW IN Anywhere
(out)
Delete the rules by the numbers in square brackets[]

#sudo ufw delete 2

Install and configure fail2ban to protect SSH

#apt install fail2ban -y
#systemctl status fail2ban

Let’s see how did fail2ban alter iptables rules:

$/usr/sbin/iptables -L -n -v

There is a new chain f2b-sshd in iptables config that is referenced in the INPUT chain rule:

Chain INPUT (policy ACCEPT 777 packets, 80681 bytes)
pkts bytes target prot opt in out source destination
1250 93157 f2b-sshd tcp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 3000
(... omitted for brevity ...)
Chain f2b-sshd (1 references)
pkts bytes target prot opt in out source destination
1223 90505 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0

fail2ban package contains a tool called fail2ban-client. It allows you to check the status of the service and interact with it (e.g., it lets you manually ban and unban IP addresses, enable and disable jails, etc.)

See which jails are active:

#fail2ban-client status
Status
|- Number of jail: 1
`- Jail list: sshd

Check the statistics for sshd jail:

#fail2ban-client status sshd
Status for the jail: sshd
|- Filter
| |- Currently failed: 0
| |- Total failed: 5
| `- File list: /var/log/auth.log
`- Actions
|- Currently banned: 1
|- Total banned: 1
`- Banned IP list: 192.168.33.1

192.168.33.1 IP address is banned from accessing SSH server. fail2ban does this by adding an entry in f2b-sshd iptables chain:

Chain f2b-sshd (1 references)
pkts bytes target     prot opt in     out     source               destination
12   696 REJECT     all  --  *      *       192.168.33.1         0.0.0.0/0            reject-with icmp-port-unreachable
1279 97855 RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0

Configuring fail2ban

The default Fail2ban filter settings will be stored in /etc/fail2ban/jail.conf file and the /etc/fail2ban/jail.d/defaults-debian.conf file

Keep in mind that you should not make any changes to that file as it might be overwritten during fail2ban upgrade.

In case you need to adjust the configuration, create /etc/fail2ban/jail.local config file with the desired changes. Please not to add same values, but only the values you want to customize.

If you want to change the default ban duration (bantime) and the number of failed attempts (maxretry), add the new config for example /etc/fail2ban/jail.local

#vim /etc/fail2ban/jail.local

Insert code below

[sshd]
#Set ban time to 1 hours
bantime = 3600
#Decrease the number of failed login attempts before banning to 3
maxretry=3

Restart the service:

#systemctl restart fail2ban

Source :
https://www.vultr.com/docs/how-to-setup-fail2ban-on-debian-9-stretch

https://blog.swmansion.com/limiting-failed-ssh-login-attempts-with-fail2ban-7da15a2313b

Vim Command

Insert, Search, Edit

You can enter insert mode from normal mode by pressing the key

i     text you type will be inserted

You can enter visual mode from normal mode by pressing the key

v     starts a visual selection

There are several more ways to enter insert mode, depending on where you want to insert the text:

i     insert at current location
a     insert after current location (append)
I     insert AT START of current line
A     insert AFTER END of current line
o     insert line below current line (open)
O     insert line ABOVE current line
s     delete character under cursor and start inserting in its place (substitute text)
S     delete all text on line and start inserting in its place (substitute line)
cw     delete to the end of current word and start inserting in its place (any movement command can be substituted for w)
cc     same as S (change line)
C     delete from the cursor to the end of line and start inserting at the cursor position

For example, starting in normal mode, if you press A then type “hello” and press Esc, you will append “hello” to the end of the current line
If you move to another line and press . you will append “hello” to that line as well (. repeats the last operation).
If you had used I (instead of A), the “hello” would have been inserted at the start of the line, and pressing . would repeat that operation.

Saving and quitting

Press Esc to enter normal mode, save the current file by entering :w (which always writes the file even if it has not changed), or :update (which only writes the file if it has changed).

Save the editing an existing file with another file name with :w filename or :saveas filename, for example, :w myfile.txt.

Quit Vim Press Esc then :q. Or the saving and quitting can be combined into one operation with :wq or :x.

Discard any changes, Press Esc then enter :q!

:wa	write all changed files (save all changes)
:xa	exit all (save all changes and close Vim)
:qa	quit all (close Vim, but not if there are unsaved changes)
:qa!	quit all (close Vim without saving—discard any changes)

Add Swap Memory on Debian 10

Add Swap Memory on Debian 10

Checking no active swap with free -h and swapon --show command

#/usr/sbin/swapon --show
#free -h
             total       used       free     shared    buffers     cached
Mem:          492M       451M        41M        17M       125M       204M
-/+ buffers/cache:       120M       371M
Swap:           0B         0B         0B

No swap space active, then checking available space on the hdd

#df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda2       20G  1.8G   17G  10% /
udev             10M     0   10M   0% /dev
tmpfs            99M   13M   87M  13% /run
tmpfs           247M     0  247M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           247M     0  247M   0% /sys/fs/cgroup

Plenty of space available on the disk with /. ,Generally, an amount equal to or double the amount of RAM on your system is a good starting point.

CREATING SWAP FILE

Since the server as 512MB of RAM, we will create a 512MB file in this guide. Type the following command to create 512MB swap file (1024 * 512MB = 524288 block size):

#dd if=/dev/zero of=/swapfile bs=1024 count=524288

Sample outputs:

524288+0 records in
524288+0 records out
536870912 bytes (537 MB) copied, 3.23347 s, 166 MB/s

Where,

if=/dev/zero : Read from /dev/zero file. /dev/zero is a special file in that provides as many null characters to build storage file called /swapfile1.
of=/swapfile1 : Read from /dev/zero write storage file to /swapfile1.
bs=1024 : Read and write 1024 BYTES bytes at a time.
count=524288 : Copy only 523288 BLOCKS input blocks.

We can verify that the correct amount of space was reserved by typing:

#ls -lh /swapfile
-rw-r--r-- 1 root root 489M Nov 3 06:56 /swapfile

Enabling the file as swap and swap space

#chmod 600 /swapfile
#/usr/sbin/mkswap /swapfile
Setting up swapspace version 1, size = 499996 KiB no label, UUID=a81f762c-ef8a-40b5-a845-52aed148aeea
#/usr/sbin/swapon /swapfile

Verify that the swap is available by typing:

#/usr/sbin/swapon --show
NAME TYPE SIZE USED PRIO
/swapfile file 488.3M 0B -1
#free -h
total used free shared buffers cached
Mem: 492M 456M 35M 17M 125M 205M
-/+ buffers/cache: 125M 367M
Swap: 488M 0B 488M

Our swap has been set up successfully

Making the Swap File Permanent, by adding the swap file to our /etc/fstab

#cp /etc/fstab /etc/fstab.bak
#echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab

Tuning Swap by Adjusting the Swappiness and Cache Pressure Setting

Set vm.swappiness and vm.vfs_cache_pressure value automatically by add the line to bottom of /etc/sysctl.conf

#vim /etc/sysctl.conf
vm.swappiness = 10
vm.vfs_cache_pressure = 50

Check the current swappiness value by typing:

cat /proc/sys/vm/swappiness
60

For a Desktop, a swappiness setting of 60 is not a bad value. For a server, you might want to move it closer to 0. Set the swappiness to a different value by using the sysctl.For instance set the swappiness to 10

#sysctl vm.swappiness=10
vm.swappiness = 10

Set value automatically by adding the line to bottom of /etc/sysctl.conf

#vim /etc/sysctl.conf
vm.swappiness=10

Save and close the file when you are finished.

Check the current Cache Pressure Setting

Configures how much the system will choose to cache inode and dentry information over other data.

#cat /proc/sys/vm/vfs_cache_pressure
100

Set this to a more conservative setting like 50 by typing:

#sysctl vm.vfs_cache_pressure=50
vm.vfs_cache_pressure = 50

Set value automatically by adding the line to bottom of /etc/sysctl.conf

#vim /etc/sysctl.conf
vm.vfs_cache_pressure=50

Save and close the file when you are finished.

Source : From https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-debian-10

HTTP/2 SSL PHP7 MariaDB on Debian 9

Requirements to enable HTTP/2 in Apache2;

  • Apache 2.4.17 or above, HTTP/2 is supported from this version and upwards
  • Prefer Debian 9 because uprade the Apache 2.4.10 on Deb 8 very complicated
  • Enable HTTPS, HTTP/2 only work over HTTPS. Also, TLS protocol version>= 1.2 with modern cipher suites is required
  • PHP7 or above
#cat /etc/*release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"

Update and upgrade the System then Install Apache2

#apt-get update -y && apt-get upgrade -y
#apt-get install apache2 -y
#apache2ctl -v
Server version: Apache/2.4.25 (Debian)

Enable and load mod_rewrite Apache2

#nano /etc/apache2/apache2.conf and replace “AllowOverride None” to “AllowOverride All”

#a2enmod rewrite
#a2enmod headers
#a2enmod expires

Install PHP7.0-FPM and other required components

#apt-get install php7.0-fpm -y && apt-get install php7.0-mysql -y && apt-get install php7.0-gd -y && apt-get install php-pear php7.0 -y

Disable the mod_php module to PHP-FPM mode

#a2dismod php7.0
ERROR: Module php7.0 does not exist!
#a2dismod mpm_prefork
Module mpm_prefork already disabled

Tell Apache to use PHP FastCGI, set the Apache use a compatible PHP implementation by changing mod_php to php-fpm (PHP FastCGI).

#a2enconf php7.0-fpm
#a2enmod proxy_fcgi
#a2enmod mpm_event
#systemctl restart apache2

Next Install SSL Certificate Apache Debian https://vpshelpdesk.com/2017/11/18/install-ssl-certificate-apache-debian

SSL test on Qualys SSL Labs Rating A Configuration https://vpshelpdesk.com/2020/03/30/ssl-test-qualys-ssl-labs-rating-configuration/

Activate HTTP/2 protocol on default-ssl.conf

Insert Protocols h2 h2c http/1.1 after <VirtualHost _default_:443> on /etc/apache2/sites-available/default-ssl.conf

#nano /etc/apache2/sites-available/default-ssl.conf

Then follow the command below

#a2enmod ssl
#a2enmod http2
#a2ensite default-ssl
#systemctl restart apache2

Check HTTP/2 at https://http2.pro https://tools.keycdn.com/http2-test 

Then install MariaDB

#apt-get -y install mariadb-server mariadb-client
#mysql_secure_installation

Set Up OpenVPN Server with sh script

Update and Upgrade the system

#apt-get update -y && apt-get upgrade -y

Find and note down your IP address, use the ip command as follows;

#ip addr
#ip a show eth0

If the public IP address not showed, use the dig command/host command

#dig +short myip.opendns.com @resolver1.opendns.com

OR

#dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'"' '{ print $2}'

Download and run openvpn-install.sh script

#wget https://git.io/vpn -O openvpn-install.sh
#wget https://vpshelpdesk.com/files/openvpn-install.sh

OR

#wget https://git.io/vpn -O openvpn-install.sh
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.76.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 23079 (23K) [text/plain]
Saving to: ‘openvpn-install.sh’

openvpn-install.sh                      100%[============================================================================>]  22.54K  --.-KB/s    in 0.001s

2020-10-26 14:33:15 (25.0 MB/s) - ‘openvpn-install.sh’ saved [23079/23079]

root@iZj6cij2s4ft9b2k2h81nmZ:/home#

Setup permissions using the chmod command:

#chmod +x openvpn-install.sh

One can view the script using a text editor such as nano/vim:

#nano openvpn-install.sh

Run openvpn-install.sh to install OpenVPN server

#./openvpn-install.sh

Follow the instruction

Welcome to this OpenVPN road warrior installer!
This server is behind NAT. What is the public IPv4 address or hostname?
Public IPv4 address / hostname [222.222.222.1]:

Which protocol should OpenVPN use?
   1) UDP (recommended)
   2) TCP
Protocol [1]:

What port should OpenVPN listen to?
Port [1194]:

Select a DNS server for the clients:
   1) Current system resolvers
   2) Google
   3) 1.1.1.1
   4) OpenDNS
   5) Quad9
   6) AdGuard
DNS server [1]:

Enter a name for the first client:
Name [client]: client1

OpenVPN installation is ready to begin.
Press any key to continue...
..................
..................
Finished!

The client configuration is available in: /root/client1.ovpn
New clients can be added by running this script again.
root@iZj6cij2s4ft9b2k2h81nmZ:~#

Check if the OpenVPN server has been installed successfully, the tun0 available with #ip addr or #ifconfig

root@iZj6cij2s4ft9b2k2h81nmZ:~# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:16:3e:06:54:02 brd ff:ff:ff:ff:ff:ff
inet 172.01.1.12/20 brd 172.01.143.255 scope global dynamic eth0
valid_lft 315358011sec preferred_lft 315358011sec
inet6 fe80::216:3eff:fe06:5402/64 scope link
valid_lft forever preferred_lft forever
3: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 100
link/none
inet 10.8.0.1/24 brd 10.8.0.255 scope global tun0
valid_lft forever preferred_lft forever

Start/stop/restart OpenVPN server with systemctl command:

#systemctl stop [email protected] 
#systemctl start [email protected] 
#systemctl restart [email protected]
#systemctl status [email protected]

To add more client run the openvpn-install.sh again

root@iZj6cij2s4ft9b2k2h81nmZ:~# ./openvpn-install.sh
OpenVPN is already installed.

Select an option:
 1) Add a new client
 2) Revoke an existing client
 3) Remove OpenVPN
 4) Exit
Option: 1

Provide a name for the client:
Name: client2
Using SSL: openssl OpenSSL 1.1.1 11 Sep 2018
Generating a RSA private key
.........................................................................................................................................................................+++++
.............................................+++++
writing new private key to '/etc/openvpn/server/easy-rsa/pki/easy-rsa-1952.6girut/tmp.4cIY4C'
-----
Using configuration from /etc/openvpn/server/easy-rsa/pki/easy-rsa-1952.6girut/tmp.07hFfF
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName :ASN.1 12:'client2'
Certificate is to be certified until Oct 24 06:48:16 2030 GMT (3650 days)

Write out database with 1 new entries
Data Base Updated

client2 added. Configuration available in: /root/client2.ovpn
root@iZj6cij2s4ft9b2k2h81nmZ:~#

To connect the OpenVPN server with OpenVPN Client download the client configuration (client.ovpn, client2.ovpn, etc), use WinSPC to download

Multiple SSL certificates on single IP address

Multiple SSL certificates on single IP address

Create the virtual host ssl inside the sites-available

#cd /etc/apache2/sites-available/
#cp default-ssl.conf web1.com-ssl.conf
#cp default-ssl.conf web2.com-ssl.conf

Make sure link on the /etc/apache2/sites-enable exist, the origin from the sites-available

#cd /etc/apache2/sites-enable
#ln -s /etc/apache2/sites-available/web1.com-ssl.conf
#ln -s /etc/apache2/sites-available/web2.com-ssl.conf
#ls -la /etc/apache2/sites-enabled
total 8
drwxr-xr-x 2 root root 4096 Apr 13 18:49 .
drwxr-xr-x 9 root root 4096 Apr 13 18:39 ..
lrwxrwxrwx 1 root root 35 Feb 15 09:57 000-default.conf -> ../sites-available/000-default.conf
lrwxrwxrwx 1 root root 58 Apr 13 18:48 web1.com-ssl.conf -> /etc/apache2/sites-available/web1.com-ssl.conf
lrwxrwxrwx 1 root root 54 Apr 13 18:49 web2.com-ssl.conf -> /etc/apache2/sites-available/web2.com-ssl.conf

Set up iptables On Debian 8 Debian 9

Faster way paste this on console

/sbin/iptables -F && /sbin/iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP && /sbin/iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP && /sbin/iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP && /sbin/iptables -I INPUT -p icmp -m icmp --icmp-type echo-request -j ACCEPT && /sbin/iptables -A INPUT -i lo -j ACCEPT && /sbin/iptables -A OUTPUT -o lo -j ACCEPT && /sbin/iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT && /sbin/iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT && /sbin/iptables -A INPUT -p tcp -m tcp --dport 21 -j ACCEPT && /sbin/iptables -A INPUT -p tcp -m tcp --dport 25 -j ACCEPT && /sbin/iptables -A INPUT -p tcp -m tcp --dport 465 -j ACCEPT && /sbin/iptables -A INPUT -p tcp -m tcp --dport 110 -j ACCEPT && /sbin/iptables -A INPUT -p tcp -m tcp --dport 995 -j ACCEPT && /sbin/iptables -A INPUT -p tcp -m tcp --dport 143 -j ACCEPT && /sbin/iptables -A INPUT -p tcp -m tcp --dport 993 -j ACCEPT && /sbin/iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT && /sbin/iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT && /sbin/iptables -P OUTPUT ACCEPT && /sbin/iptables -P INPUT DROP

New script only open port 80, 443, 25, 465,587

/sbin/iptables -F && /sbin/iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP && /sbin/iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP && /sbin/iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP && /sbin/iptables -I INPUT -p icmp -m icmp --icmp-type echo-request -j ACCEPT && /sbin/iptables -A INPUT -i lo -j ACCEPT && /sbin/iptables -A OUTPUT -o lo -j ACCEPT && /sbin/iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT && /sbin/iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT && /sbin/iptables -A INPUT -p tcp -m tcp --dport 25 -j ACCEPT && /sbin/iptables -A INPUT -p tcp -m tcp --dport 465 -j ACCEPT && /sbin/iptables -A INPUT -p tcp -m tcp --dport 587 -j ACCEPT && /sbin/iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT && /sbin/iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT && /sbin/iptables -P OUTPUT ACCEPT && /sbin/iptables -P INPUT DROP

IP-Tables are not persistent On Debian 8, save permanent the new rules to the master iptables file:

#/usr/sbin/iptables-save > /etc/iptables.up.rules

Make sure the iptables rules are started on a reboot we’ll create a new file:

#vim /etc/network/if-pre-up.d/iptables

Add these lines to it:

#!/bin/sh
/sbin/iptables-restore < /etc/iptables.up.rules

The file needs to be executable so change the permissions:

#chmod +x /etc/network/if-pre-up.d/iptables
#/usr/sbin/iptables -L
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere icmp echo-request
DROP tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,PSH,ACK,URG/NONE
DROP tcp -- anywhere anywhere tcp flags:!FIN,SYN,RST,ACK/SYN state NEW
DROP tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,SYN,RST,PSH,ACK,URG
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp
ACCEPT tcp -- anywhere anywhere tcp dpt:smtp
ACCEPT tcp -- anywhere anywhere tcp dpt:urd
ACCEPT tcp -- anywhere anywhere tcp dpt:pop3
ACCEPT tcp -- anywhere anywhere tcp dpt:pop3s
ACCEPT tcp -- anywhere anywhere tcp dpt:imap2
ACCEPT tcp -- anywhere anywhere tcp dpt:imaps
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh

Debian 10 IPtables persistent make your iptables rules persistent install iptables-persistent package:

#apt-get install iptables-persistent

Debian 10 IPtables Save to update iptables with new rules use IPtables Save

# iptables-save > /etc/iptables/rules.v4
# ip6tables-save > /etc/iptables/rules.v6

Debian 10 Restore to restore iptables configuration form iptables

# iptables-restore < /etc/iptables/rules.v4

Sudo user in Debian

Install the “sudo” Command
You need to run this command as root user:

user@debian:~$ su -
Password:
root@debian:~ # apt-get install sudo

Create a new user account.

#/usr/sbin/adduser admin

Add the user to the sudo group; By default on Debian systems, members of the group sudo are granted with sudo access. To add a user to the sudo group use the usermod command:

#usermod -aG sudo admin

Check the sudo access

#id admin
uid=1001(admin) gid=1001(admin) groups=1001(admin),27(sudo)

The user admin a member of sudo group now and to work as a root, every command must start with sudo (sudo reboot, sudo vim, sudo del, sudo mkdir, sudo……)

Error and solutions

admin@debian9:~$ sudo ifconfig
sudo: unable to resolve host (none)

Solutions

Insert hostname to /etc/hostname and /etc/hosts something like:

127.0.0.1    localhost.localdomain localhost
127.0.1.1    debian9