SSH Download Script
This script allows you to download a file from a remote SSH server and verify the md5sum to ensure no corruption during transfer. Feel free to use it as is or modify it to your liking.
Copy the code into your favorite text editor.
# www.ghorr.org - 2013
#ssh server to download from (e.g., firstname.lastname@example.org)
#path on remote host
echo "Input the path you wish to download from."
#listing files in above path and choosing the file to download
ssh $server ls $path1
echo "Choose the file you wish to download."
#path on local host
echo "Input the destination directory."
scp $server:/$path1/$file $path2/
echo "Would you like to run an md5sum? (Y/n)"
if [ "$run" = "Y" ]
#collecting the md5sums for the downloaded file
md5sumfile1=$(ssh $server md5sum $path1/$file | cut -c -32)
md5sumfile2=$(md5sum $file | cut -c -32)
#displaying the two md5sums
echo $(ssh $server md5sum $path1/$file)
echo $(md5sum $file)
#determining if the two md5sums match
if [ "$md5sumfile1" = "$md5sumfile2" ]
echo "SUCCESS, md5sums match"
echo "md5sums do NOT match"
You first need to define the server you wish to use, modify the server variable to your liking.
Save your file and place it in a directory that is easily accessible. I currently have mine placed in the bin folder in my home directory. You can also place it in the /usr/bin directory if you like. Ensure you save the script with UTF-8 encoding.
Make the script executable by running the following command in terminal, with the correct path to the script.
chmod +x [path to file]