Ad Widget

Collapse

SSH Map tool's

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aminos1985
    Junior Member
    • Sep 2010
    • 11

    #1

    SSH Map tool's

    HI,

    I have a probleme when i try to use the ssh in map tools;

    i add a new script with command : /usr/bin/ssh mylogin@{HOST.CONN}

    but it don't work

    help me
  • low10sws6
    Member
    • Oct 2008
    • 44

    #2
    you wouldn't be able to interact with the ssh session anyhow through the WEB Interface but

    only way i can see you gathering SSH information is to install EXPECT

    write a bash script
    save to file or buffer
    then echo the results

    a lot of the code is unnecessary but gives you an idea
    this will display the Running-Config on a Cisco Device
    used nmap to detect port

    Code:
    #!/bin/bash
    host=$1
    user=""
    password=""
    ssh="ssh"
    telnet="telnet"
    procget=$(nmap -p 22-23 $host |grep open)
    
    if [[ $procget == *$ssh* ]]
    then
            proc="ssh $user@$host
                  send \"\r\"
                  expect \":\"
                  send \"yes\r\""
    else
            proc="telnet $host
                    expect \":\"
                    send \"$user\r\""
    fi
    
    		VAR=$(expect -c "
    		set timeout 120
                  	spawn $proc   
    		expect \"Password:\"
                    send \"$password\r\"
                    expect \"#\"
                    send \"enable\r\"
                    expect \"#\"
                    send \"terminal length 0\r\"
                    expect \"#\"
                    send \"show run\r\"
    		log_user 0
                    log_file -a -noappend /tmp/$host
                    expect \"#\"
                    send \"\r\"
                    send \"logout\r\"
    		expect eof
                    ")
    
    readFile$(cat /tmp/$host)
    
    echo $readFile
    exit 0;

    Map Script command : /bin/bash /script/location/scriptname.sh {HOST.CONN} or {IPADDRESS}

    Comment

    • aminos1985
      Junior Member
      • Sep 2010
      • 11

      #3
      thank you for your quick answer, i will test your script tomorrow

      Comment

      Working...