Linux Admin Daily Usage

Published on Author gryzli

Shell

 

Some useful commands and bash tricks

For more extensive list of bash tips. take a look at my bash tips and tricks

 

 

Managing Big Number Of Hosts Through SSH

The following software is a golden piece: 

pssh

pscp

prsync

Combining it with ssh multiplexing, you will have some serious tool in your pocket. 

 

Speeding up SSH connections to remote servers

Some tips for speeding up your SSH connections to remote servers, especially if you are frequently reusing them.

 

Disable DNS resolve on SSHD server

( This should be executed on the host you are connecting to)

In Centos, SSHD by default has dns resolving enabled, which tries to get the reverse dns record from the connecting ip.

Put the following line in your config to disable it:

open /etc/ssh/sshd_config

Restart sshd server

systemctl restart sshd

/etc/init.d/sshd restart

 

Using SSH Multiplexing

Usefull technique when you connect to big number of servers and frequently re-connect to them.

Perfect for combining with pssh and pscp tools.

The idea of multiplexing is that once you open a ssh connection to a server, openssh will preserve your socket (until a timeout pasts) and every new connection to the same server will reuse the socket, which is very fast.

In order to use Multiplexing you need the following lines in your “~/.ssh/config” file

If you want to connect to some of the already connected hosts but with different settings (Xforwarding or -A for example), you could temporary disable ControlMaster for the new connection: 

 

 

 

Usefull settings for ~/.ssh/config

 

Removing files which filenames are starting with “–“

 

Search for all files that DOES NOT contain a given string

 

Change MOTD on Centos to a colorful message

 

Tools for working with Conntrack table

 

 

Nagios

Execute remote nrpe check

 

Dovecot

 

List parsed list of current Dovecot configuration

Sometimes you may need to parse Dovecot settings with external scripts. Going through the Dovecot config and it’s includes (+ nested syntax), could easily become automation hell.

One very helpful binary, that can help reading settings by other scripts/programs is “doveconf

 

 

MySQL 

Repairing MySQL databases/tables 

Repair single database
Repair single table of a database
Repair all databases

 

Repair all crashed tables, getting them from mysql error log

 

Usefull MySQL Queries

 

AWK