How to Find out Which Service is Running on Specific Port in Linux

train

Assalamualaikum..

Q: How do I find out which service is listening on a specific port? How do I find out what program is listening on a specific TCP Port?

A: netstat -tulpn OR netstat -npl
Wassalam..

Advertisements
Posted in Linux, Solaris | Tagged , ,

Howto Delete all Deferred Messages from Zimbra Mail Queue

queue

Assalamualaikum,

Sometimes you noticed your mail takes a bit longer than usual to get to the receiver. This issue may caused by spamming activities or your zimbra services are not working correctly.

If this issue caused by zimbra services, just restart the services by using zmcontrol restart. If the problem is still not resolve you may try to delete the deferred messages by following below steps.

Step 1: Check the Deferred Messages

Before you delete you may need to check the deferred messages first. To check deferred messages, use below command. Make sure you are login as zimbra user.

[zimbra@mailsvr ~]$  sudo ~/libexec/zmqstat
hold=0
corrupt=0
deferred=64360
active=19999
incoming=1

Step 1: Delete the Messages

if you really want to delete/flush all stuck messages in mail queue that have been deferred, issue the command below;

[zimbra@mailsvr ~]$ sudo /opt/zimbra/postfix/sbin/postsuper -d ALL
postsuper: Deleted: 83378 messages

Now check again the queue messages by follow the step 1.

thanks,

wassalam..

Posted in Linux, Zimbra | Tagged , , , , ,

Howto Configure SNMP In Centos 6

Assalamualaikum,

This guide describe howto install and do a basic configure of SNMP on a RedHat Enterprise Linux or CentOS. Probably it will work on many other *nix systems.

INSTALL
# yum install net-snmp-utils

CONFIGURE
Do a backup of the snmpd config file.
# mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.confBAK

Create a new config file.
# vi /etc/snmp/snmpd.conf

Add below line:
rocommunity public
syslocation “Rumah Nenek Aku”
syscontact nenekkuat@gmail.com

Start the snmpd service and start on boot
# /etc/init.d/snmpd start
# chkconfig snmpd on

Test 1 (Server-localhost)
# snmpwalk -v 1 -c public -O e 127.0.0.1

You should get below output:
SNMPv2-MIB::sysDescr.0 = STRING: Linux dull 2.6.18-92.1.17.el5 #1 SMP Tue Nov 4 13:45:01 EST 2008 i686
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (16748) 0:02:47.48


 

Test 2 (client)
# snmpwalk -v 1 -c public -O e 192.168.88.100     <— Target IP

TROUBLESHOOT
Error – Timeout: No Response from 192.168.88.100
Solution – Check Firewall, just disable firewall if you don’t need it. Run service iptables stop. Or you can use below rules to allow specific port (161 and 162 for snmp)

# iptables -I INPUT -p udp -m udp –dport 161 -j ACCEPT
# iptables -I INPUT -p udp -m udp –dport 162 -j ACCEPT
# service iptables restart

Wassalam..

Posted in Apache, Install, Linux, SQL | Tagged , , , ,

SCP Example Syntax

Assalamualaikum,

Secure copy or SCP is a means of securely transferring computer files between a local host and a remote host or between two remote hosts. It is based on the Secure Shell (SSH) protocol. “SCP” commonly refers to the: Secure Copy Protocol. ref wiki.

Examples

Copy the file “sample.txt” from a remote host to the local host

$ scp your_username@remotehost.edu:/tmp/sample.txt /some/local/directory

Copy the file “sample.txt” from the local host to a remote host

$ scp sample.txt your_username@remotehost.edu:/some/remote/directory

Copy the directory “hanief” from the local host to a remote host’s directory “new”

$ scp -r your_username@remotehost.edu:/some/remote/directory/new

Copy the file “sample.txt” from remote host “rh1.edu” to remote host “rh2.edu”

$ scp your_username@rh1.edu:/some/remote/directory/sample.txt \
your_username@rh2.edu:/some/remote/directory/

Copying the files “sample1.txt” and “sample2.txt” from the local host to your home directory on the remote host

$ scp sample1.txt sample2.txt your_username@remotehost.edu:~

Copy the file “sample.txt” from the local host to a remote host using port 2264

$ scp -P 2264 sample.txt your_username@remotehost.edu:/some/remote/directory

Copy multiple files from the remote host to your current directory on the local host

$ scp your_username@remotehost.edu:/some/remote/directory/\{a,b,c\} .
$ scp your_username@remotehost.edu:~/\{sample1.txt,sample2.txt\} .

scp Performance

By default scp uses the Triple-DES cipher to encrypt the data being sent. Using the Blowfish cipher has been shown to increase speed. This can be done by using option -c blowfish in the command line.

$ scp -c blowfish some_file your_username@remotehost.edu:~

It is often suggested that the -C option for compression should also be used to increase speed. The effect of compression, however, will only significantly increase speed if your connection is very slow. Otherwise it may just be adding extra burden to the CPU. An example of using blowfish and compression:

$ scp -c blowfish -C local_file your_username@remotehost.edu:~
Posted in Linux, Raspberry Pi, Solaris | Tagged , ,

Configuring yum to Use a Proxy Server

Bismillahirrahmanirrahim..

This short tutorial will show you how to configure yum to use a proxy. I’m using centOS 7 but I believed the configuration is nearly the same with our beloved CentOS 5 and 6.

open up file /etc/yum.conf

#vi /etc/yum.conf

Add below line

# The proxy server - proxy server:port number
proxy=https://skrinhitam.wordpress.com:8080
# The account details for yum connections
proxy_username=hanief
proxy_password=qwerty

save and exit.

good luck!

Posted in Linux | Tagged , , ,

Howto Set Up SSH Keys

Bismillahirrahmanirrahim..

WHAT IS SSH KEY?
SSH keys provide a more secure way of logging into a virtual private server with SSH than using a password alone. It allows user to access to the server with authorized_keys instead of using password. While a password can eventually be cracked with a brute force attack, SSH keys are nearly impossible to decipher by brute force alone. Generating a key pair provides you with two long string of characters: a public and a private key. You can place the public key on any server, and then unlock it by connecting to it with a client that already has the private key. When the two match up, the system unlocks without the need for a password. You can increase security even more by protecting the private key with a passphrase.

Step 1: Creating Your Personal Key
Open a terminal/shell and run the following command:

ssh-keygen -t rsa

You will be asked where you would like to save the key. The default setting is normally acceptable (just press enter to accept the default), but if you are setting up a key as a root user you may want to store your key in a different location.

Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa):

You will be prompted to enter a passphrase. If you choose to use a passphrase you will need to type it in every time you use the key to connect to a server (spaces are ok to use, so your passphrase can be an entire sentence if it makes it easier for you to use it). You can choose not to use a passphrase but this is generally considered less secure.

The entire key generation process looks like this:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/demo/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/demo/.ssh/id_rsa.
Your public key has been saved in /home/demo/.ssh/id_rsa.pub.
The key fingerprint is:
4a:dd:0a:c6:35:4e:3f:ed:27:38:8c:74:44:4d:93:67 root@node2
The key's randomart image is:

Note: You can change your passphrase at any time using the command:

sshkeygen -p

Step 2: Copying Your Personal Key To The Server
Before we copy your new public key to your server we will add it to the local authorized_keys file.

cd ~/.ssh
cp id_rsa.pub authorized_keys

If the authorized_keys file already exists on your local machine you will need to open the file with your favorite text editor and add the key by hand.

Now we will copy your public key to the server. In a typical server every user on the server has their own .ssh directory and their own authorized_keys file. Assuming that your user accounts are located in /home you will need to determine what user you want to login as before you copy your public key. The root user is slightly different. In most servers the root user’s ssh files are stored in /root/.ssh/.

cd ~/.ssh
scp authorized_keys root@host.servername.com:/root/.ssh/

OR you can copy the public key into the new machine’s authorized_keys file with the ssh-copy-id command. Make sure to replace the example username and IP address below.

ssh-copy-id user@123.45.56.78

Alternatively, you can paste in the keys using SSH:

cat ~/.ssh/id_rsa.pub | ssh user@123.45.56.78 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

NOTE: Just like with your local copy, if the authorized_keys file already exists on the server you will need to add the new key to the file by hand. Remember to backup the authorized_keys in your server first before you copy it using ssh. It will replace the authorized_keys on your server. I advise you to manually edit the authorized_keys on your server instead of copy using ssh.

Step 3: Logging In With Your New Key
Now that your new key has been copied to the server you can start using it for SSH logins. If your user name is the same on your local machine and on your server, you can connect simply with:

ssh host.servername.com

If your local user name and server user name are different, you can specify the user to login as using the command:

ssh user@host.servername.com

Wassalam..

Posted in Linux | Tagged , ,