Easy ssh configuration with .ssh/config file

If you ssh to many hosts then you are aware of the pain that it takes to ssh with different username and hostname. There is an alias that you can creat with native ssh though. Here I will show you the same with an example.

1
2
3
4
5
cat <<EOF >>~/.ssh/config
Host <alias>
Username <user name>
Port <port number>
Hostname <hostname>

You can optionally omit the parameters that you do not require explicitly. For example, if your port number is default then you can simply ignore the parameter.

Once this is done, you can simply ssh with the alias name, for ex:

1
ssh <alias>

Note: Remember to change the mode of the config file to “644” if the file does not exist already.

 

Add this with the key authentication for ssh and you have a password-less alias based ssh setup 🙂

Enhanced by Zemanta

Using ssmtp to send mail using gmail.

First install the package ssmtp using the command:

1
sudo yum install ssmtp

Open the configuration file for ssmtp as root user:

1
vim /etc/ssmtp/ssmtp.conf

Make the following changes to the configuration file:

root=username@gmail.com
mailhub=smtp.gmail.com:587
hostname=username@gmail.com
UseSTARTTLS=YES
AuthUser=username
AuthPass=password
FromLineOverride=yes

In order to make the default (root) “from” field be the server name,
edit the /etc/ssmtp/revaliases file as root user :

1
vi /etc/ssmtp/revaliases

And add into it the desired translation which in our Gmail examples case
will be:

root:test@example.com:smtp.gmail.com

and time to test:

1
echo "Amit Agarwal"|ssmtp <email id>

If this does not work, then you can try with -v or -vv or -vvv for ssmtp command.

Enhanced by Zemanta