Friday, August 16, 2013

Install Transmission Daemon on CentOS / Fedora / Ubuntu



Transmission is Torrent / Magnet link client vastly used on Linux, its available for almost all distros.
If you are willing to use it as headless / VM to download torrents with minimal installationon your CentOS / Fedora / RHEL distro following is the packages needs to be installed & configuration required to access transmission as web service.

here 192.168.1.1 is machine transmission daemon
192.168.1.0/24 is lan

CentOS
Install epel repo

rpm -ivh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
yum -y install transmission-daemon transmission-cli


Fedora

yum -y install transmission-daemon transmission-cli


Ubuntu

apt-get install transmission-daemon transmission-cli


Configure your machine ip / network to allow access to transmission daemon.

Make sure daemon is already stopped, otherwise changes may not work on start / restart.
CentOS

/etc/init.d/transmission-daemon stop
vi /var/lib/transmission/.config/transmission/settings.json
#from
"rpc-whitelist": "127.0.0.1",
#to
"rpc-whitelist": "192.168.1.*",

/etc/init.d/transmission-daemon start


Fedora 16
Fedora does not install transmission-daemon as a service.

killall transmission-daemon
vi ~/.config/transmission-daemon/settings.json
#from
"rpc-whitelist": "127.0.0.1",
#to
"rpc-whitelist": "192.168.1.*",
transmission-daemon


Ubuntu 11.10

/etc/init.d/transmission-daemon stop
vi /etc/transmission-daemon/settings.json
#from
"rpc-whitelist": "127.0.0.1",
#to
"rpc-whitelist": "192.168.1.*",

/etc/init.d/transmission-daemon start


Now you can access transmission using http://192.168.1.1:9091/
Ubuntu may ask for username & password. which is transmission. Thats because of following entry in settings.json
"rpc-authentication-required": false,

Sunday, August 11, 2013

Increase the root filesystem in Linux inside VMWare Workstation/VSphere without LVM

In this tutorial, I’ll explain the step by step procedure to resize the Linux root partition without losing the date. This will be really handy if you are not using LVM and you came to know that your existing root partition is run out of space.

WARNING: It’s really dangerous, so backup your data before attempting this. Please don’t blame me, if you destroy your system. You are responsible for your own actions!

Prerequisites to Start this Tutorial:

You will need to download the GParted live CD ISO file for the later use in this tutorial, so you can get this here.

Let’s start the tutorial by verifying the current root filesystem size:
df -h

1Create any file, just for verification, that we didn’t lose the data during the root partition increase process.

Turn off the virtual machine:
sudo shutdown -h now

2

Once, it shutdown, Click on the “Edit Machine Settings“, select the Hard Disk from the right side and press “Utilities“. A menu will be displayed, select “Expand” from it:

3

Current size is 4GB (It will be different in your case):

4

Increase it to your desired size(mine is 10 GB):

5

Once it will be expanded, will show you the success message:

6

Select the CD/DVD and press Browse:

7

Locate the GParted ISO that we have download in the prerequisite step:

8

Next, Power on the virtual machine to BIOS:

<9

Select the CDROM as first boot device from Boot Menu:

10

Accept the Default Settings:

11

Select “Don’t touch keymap“:

12

Press Enter to accept the default type of keyboard that have:

13

Press Enter again to start GParted in graphic mode:

14

Select the “linux-swap” from the partition layout and press the “Swapoff” from the Partition menu:

15

Select the “exteneded” from the partition layout and press the “Resize/Move“from the Partition menu:

16

Assign all unallocated space to it:

17

Press the “Resize/Move” Button after assigning all the unallocated space:

18

Next, again select the “linux-swap” from the partition layout and press the ”Resize/Move” Button:

19

Move the swap to the end of the extended partition and press the ”Resize/Move” Button:

20

Click “OK“ to the warning:

21

Once again select the “exteneded“ from the partition layout and press the “Resize/Move” button:

22

Shrink it like this, so that it’s size will only be equal to the size of the swap partition by moving the slider from left to the right side and press the “Resize/Move” button:

23

Next, select the “/dev/sda1“,which is root filesystem, from the partition layout and press the ”Resize/Move” Button:

24

Assign all unallocated space to it:

25

Then press the ”Resize/Move” Button:

26

Once you are done with the changes and sure that they are correct, press the “Apply” Button (Be Careful: changes will be irreversible once applied):

27

If everything go well, GParted will show us the “All operations successfully completed”, just press Close:

28

Reboot the system, login to the machine and verify the increase in the size of the partition of root filesystem:
df -h

29

 

Enjoy :-)

Hope this will help you!

How to verify the modulus of the CSR,Private Key and Certificate

To verify that a private key matches its certificate we need to compare their modulus.

First move to the directory,where you placed your SSL certificate.
ls

1

To view the modulus of the CSR, use the following command:
openssl req -noout -modulus -in rbgeek_com.csr | openssl md5

2Note: Please replace rbgeek_com.csr with your csr file

Next, to view the modulus of the Private Key, use the following command:
openssl rsa -noout -modulus -in rbgeek_com.key | openssl md5

3

The output of these commands are identical, which means that the Private Key was created using the supplied CSR.

Next, to view the modulus of the SSL Certificate, use the following command:
openssl x509 -noout -modulus -in rbgeek_com.crt | openssl md5

4

If everything matches (same modulus), the files are compatible.

To verify the bundle certificate with the ssl certificate, use the following command:
openssl verify -CAfile rbgeek_com.ca-bundle rbgeek_com.crt

5

OK indicate that the bundle certificate is compatible with SSL certificate.
EXTRA INFO: 

If we have CARoot certificate and chain certificate then we can create a bundle from it like this:
touch rbgeek_com.ca-bundle
cat rbgeekCARoot.crt >> rbgeek_com.ca-bundle
cat rbgeekServerCA.crt >> rbgeek_com.ca-bundle

Check the bundle file that it’s format is correct.
cat rbgeek_com.ca-bundle

Then verify it:
openssl verify -CAfile rbgeek_com.ca-bundle rbgeek_com.crt

Enjoy :-)

Hope this will help you!

How to Enable SSL in Apache2 on Ubuntu

In this tutorial, I’ll explain you that how to enable the SSL for your website under Apache2 on Ubuntu Server. For this, I’m assuming:

1. That you have a working apache2 setup on your Ubuntu Server.

2. You have correctly configured the dns records for your domain.

3. You already got a certificate from a trusted certificate authority (CA) such as Godaddy,Verisign, Comodo, etc.

Let’s verify our web server that it is up and running, before beginning this tutorial:
http://rbgeek.com

1

Create a directory inside the /etc/apache2/ directory,where we’ll save the private key, public key certificate and bundle certificate:
cd /etc/apache2/ 
sudo mkdir ssl

2

Transfer the private key, public key certificate and bundle certificate inside the /etc/apache2/ssl/ directory and verify it:
cd ssl
ls

3

We want to configure the apache in such a way that it’ll run on HTTPs and for this we need to enable ssl Apache2 module with a2enmod:
sudo a2enmod ssl

4

It will suggest you to restart apache,ignore that message for now.

Edit the ports.conf file:
sudo nano /etc/apache2/ports.conf

5

Ensure that port 443 is defined as follows and add the NameVirtualHost for port 443,comment other lines:
NameVirtualHost *:443
Listen 443

6

Open up the SSL config file:
sudo nano /etc/apache2/sites-available/default-ssl

7

Fill in the correct ServerAdmin email address,add the ServerName line and adjust the path in the DocumentRootline. Also make sure that we have a valid path for the SSL:
8

Now we need to configure the SSL site:
sudo a2ensite default-ssl

9

Restart the Apache service:
sudo /etc/init.d/apache2 restart

13

Now we should be able to connect to the server through SSL using Chrome or any other browser:

14

Verify the Certificate, that it’s the same that we got from a trusted certificate authority (CA) and configured:

15

Our Web Server is also working with http (port 80).But, we don’t want that users access it through http, we only want to access it through https. To fix this, we need to edit the /etc/apache2/sites-available/default file:
sudo nano /etc/apache2/sites-available/default

16

Delete everything and add a redirection:
RedirectPermanent / https://rbgeek.com/

17

Restart the apache2 service:
sudo /etc/init.d/apache2 restart

18

Now if we go to http://rbgeek.com/, it will redirect us to https://rbgeek.com/