Skip to main content

Posts

Showing posts with the label bash

secure shell (ssh)

Two machines running a server and a client running respectively can be connected securely via ssh.  ssh user@serverIP example: ssh tom@203.159.11.42 Every time a user logs in to the server user have to provide password for getting into the server.Whereas passwordless authentication using the public key is considered more secure while loggin to a remote server. For that the following steps should be followed: 1. Generate public/private rsa key pair: ssh-keygen -t rsa When password is asked just hit a "ENTER" to leave it empty 2.Now use ssh to create a directory ~/.ssh as user (e.g. "tom") on server(e.g. 203.159.11.42). ssh tom@203.159.11.42 -p .ssh 3.Copy key to remote server cat .ssh/id_rsa.pub | ssh tom@203.159.11.42 'cat >> .ssh/authorized_keys' After finishing these three steps, login to the remote server with ssh will not require password.

Bash script to archive different files and folders into a single folder which will be named using current timestamp

I use this script to back up files that are created in different locations. I feel easy to collect all the related files and folders to compress and save them as a single zip archive which is named as per the current date and time. #!/bin/bash # this program creates a zip archive of myFolder(containing files and folders), file1 , file2 , file3 and file4 and puts the archive in myOpDir. The name of the final zip archive will be given by the current timestamp. For eg : final_20111220_103015.zip #create a directory for putting all the files myFolder="/home/user/Desktop/myFolderWithContents" myOpDir="/home/user/Desktop/myFinalDir" file1="/home/user/Desktop/test.tcl" file2="/home/user/Desktop/test.dump.xml" file3="/home/user/Desktop/myDir/test.txt" file4="/home/user/Desktop/myDir/test.txt.xml" mkdir $myOpDir/temp # copy the files and folder to to temp dir cp -r $myFolder $myOpDir/temp/` cp $file1 $myOpDir/temp/test.tcl cp $fil...