[ImoLUG] Un "utile" script per montare filesystem della nostra rete con tunneling ssh

Luca Lama angelus491@gmail.com
Mer 11 Gen 2012 11:09:34 CET


#!/bin/sh
#needed nmap, sshfs, fusermount
#this script helps you to find and mount other filesystem you have 
access to with ssh
#
#

echo "want you to mount or umount?"
read c
a="mount"
b="umount"
if [ "$c" = "$a" ] #un modo terribile di confrontare due stringhe
then
     echo "insert one of the network addresses below within the format 
xxx.xxx.xxx.0/24 if there are none you are not connected to any network"
     ifconfig |grep inet:
     echo "address="
     read addr
     echo "select from the hosts below"
     nmap "$addr"
     echo "host="
     read host
     ping -c 1 -w 1 $host >/dev/null;
     if [ ! $? -eq 0 ]
     then
         echo " $host is not connected press enter to exit"
         read c
         exit 1
     fi
     echo mounting...
     mkdir ~/Scrivania/sftp
     sshfs $host:/ ~/Scrivania/sftp
     if [ ! $? -eq 0 ]
     then
         rm -r ~/Scrivania/sftp
         exit 1
     fi
     sleep 1s
elif [ "$c" = "$b" ]
then
     if [ ! -d ~/Scrivania/sftp ]
     then
         echo "it wasn't mounted press enter to exit"
         read c
         exit 1
     fi
     echo umounting...
     fusermount -u ~/Scrivania/sftp
     sleep 2s
     rm -r ~/Scrivania/sftp
else
     echo "quit"
fi
exit 0


Maggiori informazioni sulla lista ImoLUG