Saturday, November 14, 2020

/opt/eff.org/certbot/venv/bin/python: No module named pip.__main__; 'pip' is a package and cannot be directly executed

 I encountered this error while trying to renew Let's Encrypt Certbot-Auto

/opt/eff.org/certbot/venv/bin/python: No module named pip.__main__; 'pip' is a package and cannot be directly executed

My webserver is using Ubuntu 12.04.3 LTS (precise).

My certbot-auto is located at /data_local/app/cron_shell/lets_encrypt   (yours will be different)

I searched for a solution for 2 hours before finding this one that worked:


STEP 1 - MAKE COPY OF EXISTING CERTBOT-AUTO

cp /data_local/app/cron_shell/lets_encrypt/certbot-auto /data_local/app/cron_shell/lets_encrypt/certbot-auto-20201114


STEP 2 - EDIT THE CONTENTS OF CERTBOT-AUTO

    pip_version = StrictVersion(check_output([python, '-m', 'pip', '--version'])

        TO

    pip_version = StrictVersion(check_output(['pip', '--version'])

- and -

    command = [python, '-m', 'pip', 'install', '--no-index', '--no-deps', '-U']

        TO

    command = ['pip', 'install', '--no-index', '--no-deps', '-U']


STEP 3 - RETRY TO UPGRADE CERTBOT-AUTO
(a regular renew action without -no-upgrade will automatically do upgrade)

/data_local/app/cron_shell/lets_encrypt/certbot-auto renew

Monday, July 27, 2020

Setup Ubuntu Server with Jailed Chroot Access via SSH - restrict SSH, SCP and RSYNC [using rssh]

I have tried to create a FILE TRANSFER only linux server for a few days without success. My initial plan was to create a server which only sftp capability.  I thought by just supporting sftp I can still perform scp and rsync, but I was wrong.  I was able to create the sftp only server quite easily but which doing scp and rsync it rejected the connection with the following error:

This service allows sftp connections only.

Monday, June 1, 2020

[SOLVED] Blocked ports even when UFW disable (inactive) on Ubuntu Desktop 20.04 LTS

This problem stumped me for at least 4 hours and was very frustrating.  Basically I installed a brand new Ubuntu 20.04 Desktop LTS with all its drivers and softwares (full install).  The installation process went flawlessly.

One of the first thing I did was to install XRDP.  I prefer RDP over VNC for its speed and simplicity.  However I immediately hit a wall because the I can not connect to my Ubuntu Desktop via RDP even though I already confirmed the port 3389 is open and listening.

Here is the command you need to use to confirm Linux port is listening:

netstat -tuplen
systemctl status xrdp

Here is the command you need to confirm ports are open and answering:

telnet localhost 3389

All this time I made sure already UFW is disabled by issuing the following command:

ufw disable
ufw status verbose

I had a feeling that firewall or something is blocking, so I tested using SSH Tunnel method.  I confirmed I was able to connect to XRDP via SSH Tunnel.  So that confirmed RDP is working.  It is just the issue with network port blocking somehow.  What made it very strange is that Port 22 (SSH) is not blocked.

I even installed NGINX (webserver) on port 80 and it also was blocked! 

If you are experiencing all of the above issue... you are in luck, here is the solution:

SOLUTION! :

iptables -F


That will flush your IP Chains and that is the single command that solved all my problem above.

I have also rebooted the Ubuntu many times and iptable -F seems to be permanent (persistent).

I hope this helped somehow. 

Thanks for reading!

Saturday, May 16, 2020

[SOLVED] Wordpress Behind Reverse Proxy: Too Many Redirect Error

I have installed a wordpress behind a reverse proxy to conserve IP address and also to simplify SSL certification renewal.

However I have encountered issue with wordpress thinking that it is running on NON-HTTPS while in-fact it is.

To trick wordpress to think it is running in SSL mode, I inserted the following PHP codes on the very top of wp-config.php:


if ( (!empty( $_SERVER['HTTP_X_FORWARDED_HOST'])) ||
     (!empty( $_SERVER['HTTP_X_FORWARDED_FOR'])) ) {
    $_SERVER['HTTPS'] = 'on';
}

I hope this helps somebody. Thanks for reading -LinuxCloudCoder

Tuesday, April 28, 2020

Attempting to parse the version 1.3.0 renewal configuration file found at /etc/letsencrypt/renewal/www.domain.com.conf with version 0.31.0 of Certbot. This might not work. Cert not yet due for renewal

I have been using let's encrypt for about 2 years now and I love it!

I just experience one strange issue in one of my server which threw out this error message:

Attempting to parse the version 1.3.0 renewal configuration file found at /etc/letsencrypt/renewal/www.domain.com.conf with version 0.31.0 of Certbot. This might not work. Cert not yet due for renewal

I researched it and the problem was actually caused by having 2 installation of certbot and certbot-auto.


For some reason I was using certbot instead of certbot-auto.

certbot has been deprecated and no longer support April 2019.

I changed my crontab to the following for SOLVE this issue:


8 8 * * * certbot-auto renew --post-hook "systemctl reload nginx"


I hope this solution helped you.

Thanks for reading!

Friday, April 24, 2020

[SOLVED] Column count of mysql.user is wrong. Expected 42, found 39. The table is probably corrupted

I was stumped by this error for a few hours:

Column count of mysql.user is wrong. Expected 42, found 39. The table is probably corrupted

After wasting a few hours, I finally remember that my server was an upgraded version of MySQL.
And I was using a data structure from a older mysql server. So, there are possible inconsistent database table structure, namely the system table called 'mysql' table.

The solution to solve this issue was surprisingly simple. This single line command solved my issue:

mysql_upgrade --force -uroot -p 


The output from this command look like this:

mysql.columns_priv                                 OKmysql.db                                           OKmysql.event                                        OKmysql.func                                         OKmysql.general_log                                  OKmysql.help_category                                OKmysql.help_keyword                                 OKmysql.help_relation                                OKmysql.help_topic                                   OKmysql.host                                         OKmysql.ndb_binlog_index                             OKmysql.plugin                                       OKmysql.proc                                         OKmysql.procs_priv                                   OKmysql.proxies_priv                                 OKmysql.servers                                      OKmysql.slow_log                                     OKmysql.tables_priv                                  OKmysql.time_zone                                    OKmysql.time_zone_leap_second                        OKmysql.time_zone_name                               OKmysql.time_zone_transition                         OKmysql.time_zone_transition_type                    OKmysql.user                                         OKRunning 'mysql_fix_privilege_tables'...OK

Tuesday, February 25, 2020

By default linux server shell color are boring. Basically just using 1 color (white).  While white is okay for simple operations like installing packages, removing logs, etc...  White certainly does not help when listing directory contents.

Colorizing the content of directory really helps because it can distinguish different information using different colors, such as file vs directory. Even better showing full permission files and many more advantages.

Here is a simple instruction of how you can easily colorize your LS directory listing output for Linux (works with debian, ubuntu, centos, redhat, etc...)


In Linux edit /home/(user)/.bashrc

example:
nano /home/admin/.bashrc

Add or make sure the following lines are added:

export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'


If you like this article and like your new colorized directory listing, you may want to read my other article about using EXA (a modern replacement for LS - which uses colorized listing by default).

Saturday, February 22, 2020

Install EXA in Ubuntu - replacement for ls (directory listing)

EXA is a modern replacement for the ls (list directory content) command.

There are many benefits for using EXA (many more features you can find on EXA website)
  • Automatic default colors
  • Recursive directory listing
  • Tree view listing
  • GIT support
  • many more see EXA website

sudo apt-get install libhttp-parser2.1
cd /usr/local/src
wget https://github.com/ogham/exa/releases/download/v0.9.0/exa-linux-x86_64-0.9.0.zip
unzip exa-linux-x86_64-0.9.0.zip
sudo mv exa-linux-x86_64 /usr/local/bin/exa

If you would like to automatically replace ls with exa so that everytime you time ls it will use EXA instead, add the following lines to your .bashrc file.

Add to your .bashrc

nano ~/.bashrc

alias ls="exa"
alias ll="exa -l"