Posts

Showing posts from March, 2017

shell script count files per directory

 Using this single line scrpit, you can easily find the number of files inside each subdirectories. find . -type d -print0 | while read -d '' -r dir; do files=("$dir"/*); printf "%5d files in directory %s\n" "${#files[@]}" "$dir"; done

SSH Login Without Password Using ssh-keygen & ssh-copy-id

    1.)First we need to create Public and Private keys in the host machine.  Use the following command in the host machine.   jsmith@local-host$ ssh-keygen   If created correctly, you might find the following output. Generating public/private rsa key pair. Enter file in which to save the key (/home/jsmith/.ssh/id_rsa): [Enter key] Enter passphrase (empty for no passphrase): [Press enter key] Enter same passphrase again: [Pess enter key] Your identification has been saved in /home/jsmith/.ssh /id_rsa . Your public key has been saved in /home/jsmith/.ssh/ id_rsa.pub . The key fingerprint is: 33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9 jsmith@local-host 2.) You will see the two keys id_rsa and id_rsa.pub created in your home folder in  which id_rsa.pub is the public key which you need to copy to the destination machines  home folder   using the following command. jsmith@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host jsmith@remote-host's passw