Last active
April 10, 2017 14:02
-
-
Save strike/98fc5cece1eb7a8d1570 to your computer and use it in GitHub Desktop.
telnetpass - noninteractive ssh password provider (primitive sshpass for telnet)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ip=`gethostip -d "$1"` | |
echo $ip | |
read -p "Which user-pass use? (G - GUU, M - marina or nothing) " prompt | |
case $prompt in | |
[Gg]) | |
telnetpass "$ip" login pass en | |
;; | |
[Mm]) | |
telnetpass "$ip" login pass | |
;; | |
*) | |
false | |
;; | |
esac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect -f | |
set host [lindex $argv 0] | |
set login [lindex $argv 1] | |
set pass [lindex $argv 2] | |
set command [lindex $argv 3] | |
spawn telnet $host | |
expect -re "User" | |
send "$login\n" | |
expect -re "Password" | |
send "$pass\n" | |
expect -re ">" | |
if { $command == "en" } { | |
send "$command\n" | |
expect -re "Password" | |
send "$pass\n" | |
} else { | |
send "$command\n" | |
} | |
interact |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment