Friday, June 13, 2014

How to enable your Postgres database accessible by PgAdmin client from other machine remotely?

It is really inconvenience when I found out that I can't connect to my Postgres database (sit in Linux server) remotely through PgAdmin client tools to conduct my troubleshooting works. Even though from security perspective, should turn off the remote access. But, if my PgAdmin client is sitting within the same private network (behind the firewall), I think it is no harm to enable it. The reality is PgAdmin client on Window  is much more user friendly then I use command line tool on Linux.

Step 1 - Edit the Postgres database configuration file to enable remote machine to connect

vi /var/lib/pgsql/data/pg_hba.conf
Add the line as described below:-

host    all         all         [REMOTE MACHINE IP ADDRESS]/24       trust
Step 2 - Enable Postgres database to listen to all the IP address

vi /var/lib/pgsql/data/postgresql.conf
Edit the setting as described below

listen_addresses = '*'
Step 3 - Restart your postgresql database

service postgresql restart
Note: iptables on my Linux box has been turned off. You might want to edit the iptables setting (/etc/sysconfig/iptables) to enable port 5432 for your Linux server

iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d [REMOTE MACHINE IP ADDRESS]  --dport 5432 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s [REMOTE MACHINE IP ADDRESS] --sport 5432 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT

Note: Just in case "/etc/sysconfig/iptables" doesn't exists, maybe due to the first configuration, please type in command "service iptables save". This will save the rules at "/etc/sysconfig/iptables".

Monday, June 9, 2014

How to resolve the issue when your laptop can't connect to iPhone personal hotspot?

In order to resolve my laptop unable to join my iPhone personal hotspot issue, below are the steps that I personally has gone through.

Change the name of my phone
- Tap on "Setting" in your iPhone
- Tap on "General" menu
- Tap on "About" menu
- Tap on "Name" menu
- Change the name of your phone

Note: Once the name of your phone has changed, use your laptop to connect to the personal hotspot network with new name, you should be prompted to enter the personal hotspot passcode. But, you still unable to connect to the network for now.

Reset the WiFi password
- Tap on "Setting" in your iPhone
- Tap on "Personal Hotspot" menu
- Tap on "Wi-Fi Password"menu
- Key in the password for your personal hotspot
- Tap on "Done" button

Note: Reconnect your laptop to the hotspot with newly entered password, you should be able to get your laptop connected to your personal hotspot this time.


Monday, June 2, 2014

How to fix "User is not in the sudoers file. This incident will be reported" error when sudo bash is executed?

Below are the steps to grant user to sudo rights when message "[USER] is not in the sudoers file. This incident will be reported" is prompted upon "sudo bash" command is entered

- Type in "visudo" command
- Navigate to the bottom of the file, edit the file with user name as "[USER] ALL=(ALL) ALL".
- Save the sudo file