HowTo: Download and Install RPM File with One Command

We usually perform several steps to install RPM package:

  • Go to a temporary directory;
  • Download the RPM file;
  • Install package;
  • Remove downloaded RPM file.

All these steps can be skipped with a one command:

# rpm -ivh http://link_to_packaged.rpm

For example lets install cacti from the RPM package with this command.

# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/cacti-0.8.8a-2.el6.noarch.rpm

Use this trick, and save your time!

BE ALERT: This method should be used only if you trust a remote Server and RPM file.

HowTo: Mount Remote Windows Partition (Share) under Linux

The article describes how to mount CIFS shares manually. The shares can be on a Windows computer or on a Linux/UNIX server running Samba.

Prerequisites

1. Install cifs-utils, if it hasn’t been installed yet.

This package contains tools for mounting shares on Linux using the SMB/CIFS protocol.

# yum install cifs-utils
# sudo apt-get install cifs-utils

2. Check that NetBIOS service is running and reachable on the remote host.

Port 139 TCP – NetBIOS (Windows File and Printer Sharing).
It allows applications on separate computers to communicate over a local area network.

You can test it with telnet or nmap.

# nmap -p T:139 172.16.10.1
Nmap scan report for 172.16.10.1
Host is up (0.0011s latency).
PORT    STATE SERVICE
139/tcp open  netbios-ssn
MAC Address: 00:00:00:00:00:00 (Unknown)

# telnet 172.16.10.1 139
Trying 172.16.10.1...
Connected to 172.16.10.1.
Escape character is '^]'.

Mounting Remote Windows Share

Run all commands as root (use sudo).

Create mount point

# mkdir -p /mnt/win

Mount password protected network folder

# mount -t cifs //IP/SHARE /mnt/win/ -o dom=DOMAIN,user=USER,pass=PASS
e.g.
# mount -t cifs //172.16.10.1/private /mnt/win/ -o user=admin,pass=secret

You can use Computer/Server Name instead of IP Address.

  • ‘mount -t cifs’ – mount using the Common Internet File System (CIFS);
  • ‘-o’ – options passed to mount command;
  • ‘user=’ – username;
  • ‘pass=’ – password;
  • ‘dom=’ – domain e.g WORKGROUP (if server in domain).

Mount unprotected (guest) network folder

# mount -t cifs //IP/SAHRE /mnt/win/ -o guest
e.g.
# mount -t cifs //172.16.10.1/public /mnt/win/ -o guest
  • ‘guest’ – don’t prompt for a password.

Mount entire drive

# mount -t cifs //IP/DRIVE$ /mnt/win/ -o dom=DOMAIN,user=USER,pass=PASS
e.g.
# mount -t cifs //172.16.10.1/c$ /mnt/win/ -o user=admin,pass=secret

Unmount share

# umount /mnt/win/

OpenSSL: Find Out SSL Key Length – Linux Command Line

From the following article you’ll learn how to find out a key length of an SSL Certificate from the Linux command line, using OpenSSL utility.

The information about the key size can be retrieved from the several sources.

We can get the information about key length from the file with a private key, from the SSL certificate file or we can determine it directly from the https website.

Use the following OpenSSL commands from the Linux command line to get a key length:

Determine a Key Size from a Private Key

Linux command that retrieves a key size from a file with the private key (secret.key):

$ openssl rsa -in secret.key -text -noout | grep "Private-Key"
Private-Key: (2048 bit)

Find Out a Key Length from an SSL Certificate

Find out a key size from a file with the certificate (certificate.crt), using OpenSSL:

$ openssl x509 -in certificate.crt -text -noout | grep "Public-Key"
RSA Public-Key: (2048 bit)

Determine a Key Length from an HTTPS Site

Find out a key size from an https website, lets say google.com:

$ echo | openssl s_client -connect google.com:443 2>/dev/null | openssl x509 -text -noout | grep "Public-Key"
Public-Key: (2048 bit)

Sharing the Output of a Command with Sprunge

When I quickly need to post the output of a command, or to share some text file, I use the sprunge.us service.

It is a Free command line pastebin, dedicated to the aliens seen in Futurama, which have an organ called the “sprunger” that is used for sniffing out information.

To share a file, just do:

$ cat FILE | curl -F 'sprunge=<-' http://sprunge.us

and sprunge will send you back a URL like http://sprunge.us/VRXT, that you could share.

Append the symbol “?” followed by the language your file is written in to that URL, and you’ll get line numbering and syntax highlighting:

http://sprunge.us/VRXT?bash
http://sprunge.us/VRXT?perl
http://sprunge.us/VRXT?c

Here is the list of available programming language.

To pipe the output of any command execute:

$ COMMAND | curl -F 'sprunge=<-' http://sprunge.us

You can create a bash shell function as follows (add to your ~/.bashrc):

# Share the output of a command
sprunge() {
curl -F 'sprunge=<-' http://sprunge.us
}

Reload .bashrc file.

$ . ~/.bashrc

Now use sprunge to share any text file or the output of any command:

$ COMMAND | sprunge
$ cat FILE | sprunge

SSH Login Slow — Removing Delay

Problem: When I’m trying to log into the remote server via SSH, after I enter the UserName, it takes a lot of time before it displays the Password prompt. How to solve this problem?

Solution: Basically, a long delay during authentication process is caused by “GSS API Authentication method” or/and by “UseDNS” option. The solution is to disable the GSSAPIAuthentication method and to set the UseDNS to “no” on the SSH Server.

Edit SSH Server configuration file:

# vi /etc/ssh/sshd_config

UseDNS: Specifies whether sshd should look up the remote host name and check that the resolved host name for the remote IP address maps back to the very same IP address. The default is “yes”.

Set the UseDNS to “no” as shown below:

UseDNS no

GSSAPIAuthentication: Specifies whether user authentication based on GSSAPI is allowed. The default is “no”.

Set the GSSAPIAuthentication to “no”:

GSSAPIAuthentication no

Restart the OpenSSH server to apply changes

For Fedora/Centos/RHEL etc.:

# service sshd restart

For Debian/Ubuntu/LinuxMint etc.:

# sudo service ssh restart

Now you could connect to your Server with SSH quick as usual.

HowTo: Change TSM Node’s Password

A short note about how to change TSM node’s password and remove its expiration.

Change Node’s Password from TSM Client

Execute set password from TSM Client command line, to change a node’s password.

tsm-cli> set password

Reset Node’s Password from TSM Server

Use the following syntax on TSM Server command line to set a password for a node.

tsm-serv> update node NODENAME PASSWORD

Remove Password Expiration

Set the option passexp=0 on TSM Server to disable password expiration for a node.

tsm-serv> update node NODENAME passexp=0

HowTo: Install TSM Client on CentOS/RHEL

This guide describes the process of installation and basic configuration of TSM (Tivoli Storage Manager) Client on CentOS/RHEL.

Downloading the TSM Client

Download the archive with the latest TSM Client for your OS from IBM public FTP.

For example, lets download and unpack TSM Client 6.3.1.0 for Centos 6.3 64-Bit:

# mkdir -p /tmp/tsminstall
# cd /tmp/tsminstall
# wget ftp://public.dhe.ibm.com/storage/tivoli-storage-management/maintenance/client/v6r3/Linux/LinuxX86/BA/v631/6.3.1.0-TIV-TSMBAC-LinuxX86.tar
# tar xvf 6.3.1.0-TIV-TSMBAC-LinuxX86.tar

After unpacking you should see the following files:

README_enu.htm
README_api_enu.htm
TIVsm-API64.x86_64.rpm
TIVsm-BA.x86_64.rpm
TIVsm-BAhdw.x86_64.rpm
TIVsm-JBB.x86_64.rpm
TIVsm-APIcit.x86_64.rpm
TIVsm-BAcit.x86_64.rpm
TIVsm-filepath-6.3.1-0-rhel55.x86_64.rpm
TIVsm-filepath-6.3.1-0-rhel60.x86_64.rpm
TIVsm-filepath-6.3.1-0-sles10sp3.x86_64.rpm
TIVsm-filepath-6.3.1-0-sles11sp1.x86_64.rpm
gskcrypt64-8.0.14.14.linux.x86_64.rpm
gskssl64-8.0.14.14.linux.x86_64.rpm

The packages that are needed for installation are highlighted.

Installing TSM Client

1. Resolving Dependences

Install gskcrypt and gskssl. Normally, these libraries can be found in an archive with the TSM Client.

# rpm -ivh gskcrypt64-8.0.14.14.linux.x86_64.rpm
# rpm -ivh gskssl64-8.0.14.14.linux.x86_64.rpm

2. Installing TSM Client

Use yum localinstall to installing TSM client from rpm files. In this case the enabled repositories will be used to resolve dependencies.

# yum localinstall TIVsm-API64.x86_64.rpm
# yum localinstall TIVsm-BA.x86_64.rpm

You can remove the temporary folder, if the installation has completed successfully.

# rm -rf /tmp/tsminstall

TSM Client Configuration

Add the TSM client service to autostart:

# chkconfig --add dsmcad
# chkconfig dsmcad on

Create configuration files from the samples:

# cd /opt/tivoli/tsm/client/ba/bin/
# cp dsm.opt.smp dsm.opt
# cp dsm.sys.smp dsm.sys

Open configuration files and append your settings.

The content of /opt/tivoli/tsm/client/ba/bin/dsm.sys – Example:

SErvername TSM-SERVER-1
COMMMethod TCPip
TCPPort 1500
TCPServeraddress 192.168.0.5
PASSWORDAccess generate
NODename CLIENT-NODE-12345
SCHEDMODe PROMPTED
MANAGEDServices schedule
ERRORLOGName /opt/tivoli/tsm/client/ba/bin/dsmerror.log
ERRORLOGRetention 7 D
SCHEDLOGName /opt/tivoli/tsm/client/ba/bin/dsmsched.log
SCHEDLOGRetention 7 D
DEDUPLICATION yes

The content of /opt/tivoli/tsm/client/ba/bin/dsm.opt – Example:

SErvername TSM-SERVER-1

TSM Server Configuration

Register the new node on your TSM Server.

Perform the following steps in the TSM Server’s console, if you haven’t registered the new node yet.

1. Register the new node

tsm> register node [NODE-NAME] [NODE-PASSWORD] domain=[DOMAIN]

Example:

tsm> register node CLIENT-NODE-12345 PASSW0RD domain=STANDARD

2. Associate the new node with a schedule

tsm> define assoc [DOMAIN] [SCHEDULE] [NODE-NAME]

Example:

tsm> define assoc STANDARD INCR_20H CLIENT-NODE-12345

These step are enough. Now logout and go back to your server.

Completing the TSM Client Configuration

Establish the first connection to TSM server from the client:

# dsmc query session

Enter the ‘user id’ (the name of your node) and the ‘password’.

If the session was successfully established, the password will be stored, and you won’t need to type it anymore.

Start the TSM client service:

# service dsmcad start

In a few minutes check the last schedule logs. Verify that the next backup has been successfully scheduled.

# tail /opt/tivoli/tsm/client/ba/bin/dsmsched.log

In case of any problems check the last error logs:

# tail /opt/tivoli/tsm/client/ba/bin/dsmerror.log

Good Luck and Have Fun!

Linux Proxy Server Settings – Set Proxy For Command Line

To use a proxy on the Linux command-line, you can set the environment variables http_proxy, https_proxy or ftp_proxy, depending on the traffic type.

These proxy server settings are used by the almost all Linux command-line utilities, e.g. ftp, wget, curl, ssh, apt-get, yum and others.

If you don’t know yet which proxy server to use, you can take one from the lists of the free public proxy servers at the end of this article. (more…)

Installing the OCS Inventory Agent 1.x on CentOS/RHEL

Open Computer and Software Inventory (OCS-Inventory) – is a free software that enables users to inventory their IT assets.

OCS collects information about the hardware and software of networked machines running the OCS client program (“OCS Inventory Agent”).

This guide describes how to install OCS-Inventory Client (ocsinventory-agent) Series 1.x on CentOS/RHEL.

Adding EPEL Repository

There is no OCS Inventory Agent package in the standard repositories, so we will take it from EPEL repository.

If you need, you can use the guide that describes the installation process of EPEL repository.

The example of EPEL installation on CentOS 6.4 – 64bit:

# wget http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6
# rpm --import RPM-GPG-KEY-EPEL-6
# rm -f RPM-GPG-KEY-EPEL-6
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
# rm -f epel-release-6-8.noarch.rpm

Installing OCS Inventory Agent

Install the OCS Inventory Agent 1.x with the following command:

# yum install ocsinventory-agent

Configuring OCS Inventory Agent

Open the configuration file.

# vi /etc/ocsinventory/ocsinventory-agent.cfg

Uncomment the following lines. Set a tag for the current server and the address of your OCS server.

server = http://your.ocs.server/ocsinventory
tag = your_tag

Change the line local = /var/lib/ocsinventory-agent to basevardir = /var/lib/ocsinventory-agent. Save and close the file.

Forcing the Inventory

By default, the ‘ocsinventory-agent’ script was added to ‘cron.hourly’ and it will send the inventory to your OCS server every hour.

I advice you to move the script to ‘cron.daily’, to send the inventory once a day. In most cases it will be enough.

# mv /etc/cron.hourly/ocsinventory-agent /etc/cron.daily/

To force the sending of inventory execute the following:

# /usr/sbin/ocsinventory-agent

Troubleshooting

The problems I have encountered.

Packages perl-XML-Simple and perl-Net-IP not available

I had the following errors on RHEL 6.4 x86_64 system.

Error: Package: ocsinventory-agent-1.1.2.1-1.el6.noarch (epel)
           Requires: perl(XML::Simple)
Error: Package: ocsinventory-agent-1.1.2.1-1.el6.noarch (epel)
           Requires: perl(Net::IP)
# yum install perl-XML-Simple perl-Net-IP
***
No package perl-XML-Simple available.
No package perl-Net-IP available.

It means that your system is not subscribed to the RHEL ‘optional’ channel.

You can manually subscribe your system or install the required packages from rpm.

Search for perl-XML-Simple and perl-Net-IP on rpmfind.net and install them manually.

Example:

# rpm -ivh ftp://rpmfind.net/linux/centos/6.4/os/x86_64/Packages/perl-XML-Simple-2.18-6.el6.noarch.rpm
# rpm -ivh ftp://rpmfind.net/linux/centos/6.4/os/x86_64/Packages/perl-Net-IP-1.25-13.el6.noarch.rpm

500 Can’t connect to your.ocs.server:80 (connect: Connection timed out)

The following error in ocsinventory-agent.log means that OCS server is not reachable.

Test the connection with ping and telnet.

# telnet your.ocs.server 80
Trying your.ocs.server ...
telnet: connect to address your.ocs.server: Connection timed out

Check your firewall.

MySQL Server Installation and Initial Configuration on CentOS/RHEL

MySQL is the world’s most popular open source relational database management system that runs as a server providing multi-user access to a number of databases.

This guide explains how to install and perform the initial secure configuration of MySQL Server on CentOS/RHEL based systems.

MySQL Server Installation

Install MySQL Server and MySQL Client using ‘yum’ command.

# yum install mysql-server mysql

Set the MySQL server daemon to start at boot.

# chkconfig mysqld on

Start MySQL.

# service mysqld start

MySQL Server Initial Configuration

Run MySQL secure installation script.

# /usr/bin/mysql_secure_installation

Note: Running all parts of this script is recommended for all MySQL servers in production use! Please read each step carefully!

Perform the next steps:

  • [Y] – Set the root password;
  • [Y] – Remove anonymous users;
  • [Y] – Disallow root login remotely;
  • [Y] – Remove test database and access to it;
  • [Y] – Reload privilege tables.

Once these steps are complete you would be able to log into MySQL Server console with the following command:

# mysql -u root -p