Friday, December 4, 2009

Who Invented Poptrapica

capture telnet / ssh to check link status

Today I'm going to have a script I found online ( here ) and modified slightly to capture in a standard output log of remote connections using telnet or ssh.

the script called ssh.sh telnet.sh and both require as parameters the ip and name of the log.

1) Log telnet


# / bin / bash

if ["$ #" == "0"] Then

echo "Usage:"
echo "ip telnet log-name"
echo " logs to / var / log use the-z switch Before telnet arguments "
exit
fi

if [" $ 1 "=="-z "]
Then
logname = $ 2
shift 2
echo" Trying $ 3 "
else

if [ "$2" == "" ]
then
echo "Usage: telnet.sh "
echo " "
echo "Logs to: "
echo " /var/log use the -z switch before telnet arguments"
exit
else
logname=$2-$(date +%y%d%h%M%S)
echo "Trying $1"
echo "conectado a $2"
fi
fi
#log data with date, or user input
telnet $1
2)Log ssh


#!/bin/bash
if [ "$#" == "0" ]
then
echo "Usage:"
echo " telnet ip log-name"
echo "logs to /var/log use the -z switch before telnet arguments"
exit
fi

if [ "$1" == "-z" ]
then
logname=$2
shift 2
echo "Trying $3"
else

if [ "$2" == "" ]
then
echo "Usage: telnet.sh
"
echo " "
echo "Logs to:" echo "/ var / log use the-z switch Before telnet arguments"
exit
else
logname = $ 2 - $ (date +% y% d% H% M% S)
echo "Trying $ 1 "
echo" Connected to $ 2 "
fi
fi
# log data with date, or user input
ssh $ 1
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Argentina
.

0 comments:

Post a Comment