Macro for SSH
Post new topic Reply to topic  [ 33 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Macro for SSH
PostPosted: Mon May 14, 2007 8:37 am 
Offline
Newbie

Joined: Mon May 14, 2007 8:30 am
Posts: 17
My question is i'm trying to run a .ttl with SSH. What i want this to do is login and do major changes to Enterasys Routers (over 400). I have made one for telnet but the code is not recognized when i use SSH. I want to have a pool of IP address and once it gets done with one router it goes to the next and the next and so on. here is my code for telnet. Please Help!!!

; Sample macro for Tera Term
; Telnet login

; start logging to confirm it worked
logopen 'enterasysresults.log' 1 0

; open txt file of ip numbers
fileopen fhandle 'ipnum' 0
; if EOF close file
if result goto fclose

; setup looping routine
:loop

;read ip file until EOF
filereadln fhandle openip
if result goto fclose

; connect Tera Term to ip
connect openip


;append to logfile until script is complete
logopen 'enterasysresults.log' 1 1

; set username & pw prompts & values
UsernamePrompt = 'Username:'
Username = 'XXXXXXXXX'
PasswordPrompt = 'Password:'
Password = 'XXXXXXX'
Finiprompt = 'Matrix E7 Platinum(su)->'

; login
wait UsernamePrompt
sendln Username

wait PasswordPrompt
sendln Password

; OK, login complete.
; setup defaults & clrscreen
timeout = 1

; wait for prompt & send commands...
wait Finiprompt
sendln 'en'
sendln 'show run'
sendln ' '
sendln ' '
sendln ' '

;this line should wait for prompt again & then continue
;but it appears the timeout is expiring instead
waitln Finiprompt

; go to next ip
logwrite #13#10#13#10
logwrite openip
logwrite ' done'#13#10
logclose
closett

goto loop

:fclose
fileclose fhandle



:?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 8:54 am 
Offline
Moderator, LogMeTT developer
User avatar

Joined: Sat Jan 08, 2005 7:52 am
Posts: 1143
Location: Seattle, WA, USA
Check the following 2 threads to find the answers on your questions:
http://logmett.com/forum/viewtopic.php?t=449
http://logmett.com/forum/viewtopic.php?t=28

_________________
Thanks.
Best regards,
// Boris


Top
 Profile E-mail  
 
 Post subject: TELNET / SSH
PostPosted: Mon May 14, 2007 9:07 am 
Offline
Newbie

Joined: Mon May 14, 2007 8:30 am
Posts: 17
I tried that code and changed it to SSH and it still couldnt recognize it.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 9:17 am 
Offline
Moderator, LogMeTT developer
User avatar

Joined: Sat Jan 08, 2005 7:52 am
Posts: 1143
Location: Seattle, WA, USA
Could you please explain what do you exactly mean by "the code is not recognized" ?
Have you tried to enter all your commands "by hand" ? Did they work?

Paste here the output of your screen, that will give us better idea of what is the issue.

_________________
Thanks.
Best regards,
// Boris


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Mon May 14, 2007 9:28 am 
Offline
Newbie

Joined: Mon May 14, 2007 8:30 am
Posts: 17
connect 'openip :22' ; not sure of the syntax here or what to connect 2
wait 'Username:'
sendln 'XXXX'
wait 'Password:'
sendln 'XXXXXXX'
wait 'hostname>'
sendln 'ssh 10.3.0.254'


fileopen filehandle 'ip.txt' 0
filereadln filehandle line

while result=0
connect_line='ssh '
strconcat connect_line line
sendln connect_line
wait 'Username:'
sendln 'xxxxx'
wait 'Password:'
sendln 'xxxxx'
timeout = 1
sendln 'en'

filereadln filehandle line
endwhile

fileclose filehandle

exit

I am not sure what to connect to. Also i dont want to type in the username and password.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 9:41 am 
Offline
Moderator, LogMeTT developer
User avatar

Joined: Sat Jan 08, 2005 7:52 am
Posts: 1143
Location: Seattle, WA, USA
Your connect string does not look right to me. Let's take 1 step a time.

Create new macro and add the followig line:
connect 'myserver /ssh /2 /auth=password /user=username /passwd=password'


Replace myserver with your server name or IP address. Replace username with actual username and password (at the end of the line) with actual password. Do not change /auth=password part of the string. Are you able to connect using this syntax ?

_________________
Thanks.
Best regards,
// Boris


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Mon May 14, 2007 9:51 am 
Offline
Newbie

Joined: Mon May 14, 2007 8:30 am
Posts: 17
when i put an IP in there, from one of our routers i get an error says SSH2 autologin error. If i go to the main menu and type it it works. so something with the autologin is breaking the macro


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 10:03 am 
Offline
Moderator, LogMeTT developer
User avatar

Joined: Sat Jan 08, 2005 7:52 am
Posts: 1143
Location: Seattle, WA, USA
When logging in interactive mode do you use plain password to log in (phassphrase), RSA/DSA key or challenge/response option?

_________________
Thanks.
Best regards,
// Boris


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Tue May 15, 2007 6:15 am 
Offline
Newbie

Joined: Mon May 14, 2007 8:30 am
Posts: 17
I use plaintext. we have a standard word we use. i downloaded teraterm from http://ttssh2.sourceforge.jp/ where i click the icon on the bottom right corner and go to list configuration and i add some of our sites into and i put ssh and put the passphrase in it and then try and execute it it just has ssh 2.0.0.0 on the screen.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 7:13 am 
Offline
Moderator, LogMeTT developer
User avatar

Joined: Sat Jan 08, 2005 7:52 am
Posts: 1143
Location: Seattle, WA, USA
Quote:
i click the icon on the bottom right corner

Are you talking about LogMeTT application?

Could you try to start ttermpro.exe from TeraTerm installation directory, then in New Connection window enter your IP address, select service SSH, select SSH version SSH2, make sure that TCP port is set to 22 and click Ok. Another window will show up where you will need to enter your username and password. Could you please do this "pure" test and let us know if it works.

_________________
Thanks.
Best regards,
// Boris


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Tue May 15, 2007 7:16 am 
Offline
Newbie

Joined: Mon May 14, 2007 8:30 am
Posts: 17
The pure test works. When i add a new one i have to store the key and all the but once its in there it works fine. I was talking about the TeraTerm Menu on the bottom right corner.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 7:21 am 
Offline
Moderator, LogMeTT developer
User avatar

Joined: Sat Jan 08, 2005 7:52 am
Posts: 1143
Location: Seattle, WA, USA
TeraTerm Menu is old application that is not supported any more (as far as I know). You can do the same and much more using my LogMeTT tool. It is part of TeraTerm package. Check LogMeTT help file to learn about it.

_________________
Thanks.
Best regards,
// Boris


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Tue May 15, 2007 10:08 am 
Offline
Newbie

Joined: Mon May 14, 2007 8:30 am
Posts: 17
Do you know why the autologin fails? And the version of tera term might not be any good now a days. Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 10:23 am 
Offline
Moderator, LogMeTT developer
User avatar

Joined: Sat Jan 08, 2005 7:52 am
Posts: 1143
Location: Seattle, WA, USA
Install the latest version 4.52 and try again http://logmett.com/freeware/TeraTerm/ ... f8_452.exe

_________________
Thanks.
Best regards,
// Boris


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Tue May 15, 2007 10:54 am 
Offline
Newbie

Joined: Mon May 14, 2007 8:30 am
Posts: 17
Unfort. same thing. It looks like its working and then it says autologin fails. I can send you my script i have used for telnet and it works like a charm. Just can't get it to work for SSH because the autologin and i think the RSA Key needs to be in the ssh_known_hosts section before it can work with every IP correct me if i'm wrong


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 33 posts ]  Go to page 1, 2, 3  Next

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group