Saturday, March 10, 2018

How to create SSH tunnel and use it for web browsing

Command

ssh -D 12345 -C -q -N <username>@<ip or FQDN> -p 23456

Explanation

-D ssh will act as a SOCKS server for the given port
-C Compress data
-q quiet mode. warning and diagnostic messages will be suppressed
-N Do not execute a remote command.  just forwarding ports.
<username>@<ip or FQDN> Connection string to SSH server
-p SSH server port. (if it's usual port 22, you can ignore this parameter)

In addition to above options you can use -f option to push ssh command to background

Executing above command will create a SSH tunnel which supports SOCKS protocol.

How to configure Firefox to use the SSH tunnel 

Go to proxy settings and use localhost as "SOCKS Host" and the port you used for the tunnel as the Port (see the screenshot below)

How to configure Firefox to forward DNS queries to the SSH tunnel

Use "Proxy DNS when using SOCKS v5" in proxy settings or set "network.proxy.socks_remote_dns" to "true" via about:config to get DNS queries resolved via the tunnel. Otherwise the browser will use DNS server configured in your network interface or ISP's DNS servers.


Proxy Settings in Firefox

How to disable WebRTC in Firefox

Important: Please read http://swapoff.blogspot.com/2018/08/avoid-webrtc-leak-if-you-use-browser.html for instructions to disable WebRTC.

Thursday, December 28, 2017

avrdude: stk500_recv(): programmer is not responding error


For the first time, I have started to play with Arduino. I bought an Arduino Pro mini and FT232RL USB to Serial Adaptor Module to connect it to PC for programming.

So I plugged it to my Fedora PC, Started the IDE, configured everything correctly and tried to program it.

Instead of success what I got was annoying error "avrdude: stk500_recv(): programmer is not responding error". After doing about an hour of investigations, I was still unable to find a clue.

Then I decided to plug the FT232RL module to an on-board USB port instead of the USB port I used in the front panel. Surprise!!! It worked!!!.

So the issue was with the USB port in the front panel.


Tl;DR:
Use on-board USB ports. Do not use front panel USB ports to program Arduino.

Tuesday, December 19, 2017

Getting "HTTP Error 402: Payment Required" warning from youtube-dl

If you get below warning message when you try to download a YouTube video using youtube-dl on an OVH dedicated host, use --force-ipv4 option with youtube-dl.
WARNING: unable to download video info webpage: HTTP Error 402: Payment Require

Sunday, December 3, 2017

How to install and configure Kodi on Linux to use NFS and MySQL

Plex and Kodi are very popular media player software. Both of these software have pros and cons in various aspects such as open source vs closed source, free vs paid, server end transcoding vs client end transcoding etc.

When it comes to configurations, Plex is easier to configure than Kodi. However if you are a Linux user, configuring Kodi is not difficult. Actually it is easier than what I thought.

My use case is sharing media files across a LAN. An Espressobin works as the centralized headless media source, a Fedora desktop and an Android Tab as the Kodi clients.

I chose NFS to share the files and MySQL to share the Libraries.

1. Install and configure NFS server on the NAS


I'm using Armbian on my Espressobin, hence the package management tool is apt-get. 

apt-get install nfs-kernel-server

Then I have configured /etc/exports file which is the configuration file for NFS server to share the directory where my media files are.

Methods of configuring this file is explained in Kodi Wiki in detailed manner.
http://kodi.wiki/view/NFS#NFS_sharing_from_Linux

I used option one where all UIDs connected to the NFS server are mapped to UID 65534 (i.e. user nobody)

Content of my /etc/exports file,

root@espressobin:~# cat /etc/exports  | grep -v '#'
/mnt/kodi_test 192.168.8.0/24(rw,all_squash,insecure)


Then I executed exportfs -ra command to refresh the NFS shares.

At this point, the NFS share has been successfully configured.

 

2. Install and configure MySQL server on the NAS


The steps required for this are well documented in the Kodi Wiki,
http://kodi.wiki/view/MySQL/Setting_up_MySQL

In brief the steps are,
  • Install MySQL server,
apt-get install mysql-server

  • Change Bind Address,
Change bind-address in /etc/mysql/mysql.conf.d/mysqld.cnf file

  • Restart MySQL Server,
service mysql restart

  • Execute SQLs to create and configure required database user in MySQL server,
mysql -u root -p

CREATE USER 'kodi' IDENTIFIED BY 'kodi';
GRANT ALL ON *.* TO 'kodi';
flush privileges;


Now I have finished configuring the server side. I have installed and configured NFS and MySQL on my NAS. Now it's time to configure client side. So I installed Kodi on my Fedora desktop.

3. Use MySQL in Kodi


Even though I have created MySQL server and the required MYSQL users on the NAS, Kodi runs on my Desktop must be configured to use the MySQL server.

For that I need to create a XML file called advancedsettings.xml and put it to a directory in each Kodi clients. The directory location is OS specific and the correct location is documented here,
http://kodi.wiki/view/Userdata#Location_of_the_userdata_folder

So I have created my advancedsettings.xml in ~/.kodi/userdata/  in my Fedora desktop machine.

[user@localhost userdata]$ pwd
/home/user/.kodi/userdata


[user@localhost userdata]$ cat advancedsettings.xml
<advancedsettings>
  <videodatabase>
    <type>mysql</type>
    <host>192.168.8.102</host>
    <port>3306</port>
    <user>kodi</user>
    <pass>kodi</pass>
  </videodatabase>
  <musicdatabase>
    <type>mysql</type>
    <host>192.168.8.102</host>
    <port>3306</port>
    <user>kodi</user>
    <pass>kodi</pass>
  </musicdatabase>
  <videolibrary>
    <importwatchedstate>true</importwatchedstate>
    <importresumepoint>true</importresumepoint>
  </videolibrary>
</advancedsettings>


4. Use NFS share in Kodi


I started Kodi on the Fedora desktop and added the NFS share as the media source.

Instruction on adding a shared source is documented here,
http://kodi.wiki/view/Adding_video_sources#Adding_Remote_sources

In brief the steps are,
  • Click on the settings icon
  • Click on Media Settings
  • Click on Library
  • Select  Videos from "Manage Sources"
  • Click on Add Videos
  • Then Click on Browse from "Add Video Source" window
  • Choose Network File System (NFS) option from the drop down

That's it. the Espressobin NAS has been configured,
  • to share content via NFS to Kodi running on devices connected to my LAN
  • to maintain a centralized Kodi library in MySQL server running on the same NAS.

Was that difficult? I don't think so.

Saturday, October 21, 2017

E3372 USB Modem not working issue on Fedora 26

Today I installed Fedora 26 on my Laptop (HP EliteBook).  After that I wanted to connect my USB Modem E3372 to connect to the internet. Ah! Surprise!! It didn't work. Whenever I tried to enable the connection through the GUI, it stopped connecting immediately. This modem had no issues with Fedora 25 installed on my Desktop.

After analyzing the logs (journalctl -xe) I was able to find the issue.  Actually a required plugin was not installed with the OS installation or even with the dnf upgrade I did after the OS installation.

Oct 20 17:21:57 localhost.localdomain NetworkManager[739]: <info>  [1508534517.2585] device (ttyUSB0): state change: config -> ip-config (reason 'none', internal state 'managed')
Oct 20 17:21:57 localhost.localdomain NetworkManager[739]: <warn>  [1508534517.2586] device (ttyUSB0): interface ttyUSB1 not up for IP configuration
Oct 20 17:21:57 localhost.localdomain NetworkManager[739]: <info>  [1508534517.2586] (ttyUSB0): using modem-specified IP timeout: 20 seconds
Oct 20 17:21:57 localhost.localdomain NetworkManager[739]: <error> [1508534517.2587] (ttyUSB0): error starting PPP: the PPP plugin /usr/lib64/NetworkManager/libnm-ppp-plugin.so is not installed
Oct 20 17:21:57 localhost.localdomain NetworkManager[739]: <info>  [1508534517.2588] device (ttyUSB0): state change: ip-config -> failed (reason 'ppp-start-failed', internal state 'managed')
Oct 20 17:21:57 localhost.localdomain NetworkManager[739]: <warn>  [1508534517.2593] device (ttyUSB0): Activation: failed for connection


The library is provided by a package called NetworkManager-ppp

dnf provides /usr/lib64/NetworkManager/libnm-ppp-plugin.so
Last metadata expiration check: 1:06:38 ago on Fri 20 Oct 2017 04:27:22 PM EDT.
NetworkManager-ppp-1:1.8.2-1.fc26.x86_64 : PPP plugin for NetworkManager
Repo        : updates
Matched from:
Filename    : /usr/lib64/NetworkManager/libnm-ppp-plugin.so

NetworkManager-ppp-1:1.8.0-6.fc26.x86_64 : PPP plugin for NetworkManager
Repo        : fedora
Matched from:
Filename    : /usr/lib64/NetworkManager/libnm-ppp-plugin.so



Then I installed the package

[root@localhost ~]# dnf install  NetworkManager-ppp

Here we go. The modem started to working.!!!