Posted: November 9, 2011 at 5:25 pm | Tags: bash script duration, bash script execution time, shell script execution time, show bash script duration, show bash script execution time, show shell script execution time
Simple BASH script example for showing the elapsed time for a script to execute:
#!/bin/bash
start_time=`date +%s`
end_time=`date +%s`
time_elapsed=$(($end_time-$start_time))
echo "Script execution took $time_elapsed seconds."
Posted: November 8, 2011 at 6:06 pm | Tags: CentOS 5 passwordless SSH, CentOS 6 passwordless SSH, Debian passwordless SSH, Linux passwordless SSH, Passwordless SSH, quick passwordless SSH, simple passwordless SSH, Ubuntu passwordless SSH
Scenario:
You have two servers, ServerA and ServerB – you would like ServerA to be able to SSH in to ServerB without a password. Use this simple tutorial to achieve this:
Step 1: Generate public key on ServerA
SSH in to ServerA and enter the following command. Keep pressing enter (accept the defaults) – do not enter a passphrase.
ssh-keygen -t dsa
This should have generated a file, /root/.ssh/id_dsa.pub
Copy the contents of the file above:
cat /root/.ssh/id_dsa.pub
Step2: Copy ServerA’s public key to ServerB
SSH in to ServerB and paste the contents from /root/.ssh/id_dsa.pub from ServerA (above) in to /root/.ssh/authorized_keys on ServerB:
If the /root/.ssh directory does not exist, create it first:
mkdir /root/.ssh
vim /root/.ssh/authorized_keys
Set the required permissions on the authorized_keys file:
chmod 0600 /root/.ssh/authorized_keys
Now try and SSH to ServerA from ServerB – you should not be prompted for a password. The same process can be used for other users, apart from root. If you want ServerB to have passwordless SSH access to ServerA, perform the same steps as above, but swap ServerA for ServerB the next time you do it.