Jump to content

PuTTY Security Alert


moraist
 Share

Recommended Posts

Hi Guys,

I am new in the AutoIT language and I am trying to create a script using PuTTY to make some change in the network devices, such as switches and routers.

The script is working, but sometimes it is stopping by itself because of the PuTTY's Security Alert pop-up.

I already tried fix this problem but I not got success until now, I just need click "Sim" button and run comammds in the PuTTY session. Which the best way to handle the PuTTY Pop-Up?

This is my script:

#include <file.au3>
#include <Array.au3>

$ipFile = FileOpen("C:\Tools\ips.txt", 0)
$ipFailed = FileOpen("C:\Tools\Failed.txt", 1)
$pingFailed = FileOpen("C:\Tools\pingFailed.txt", 1)
$ipSuccess = FileOpen("C:\Tools\Success.txt", 1)

Local $user = InputBox("Credentials", "Enter the username")
Local $pass = InputBox("Credentials", "Enter the password")

$app = ("putty.exe -l" & " " & $user & " " & "-pw" & " " & $pass)

If FileGetSize("C:\Tools\ips.txt") = 0 Then
   MsgBox(0, "ERROR", "The file is empty!")
Else
   While 1
      $ipaddr = FileReadLine($ipFile)
      If @error = -1 Then ExitLoop
         $iPing = Ping($ipaddr, 1)
         If $iPing = 0 Then
            FileWrite($pingFailed, $ipaddr & @CRLF)
         Else
            $statusSVC = RunWait("portqry.exe -n " & $ipaddr & " -e 22 " & " -q")
            If $statusSVC = 1 Then
               FileWrite($ipFailed, $ipaddr & @CRLF)
            Else
               $conn = Run (@ComSpec & " /c " & $app & ' ' & $ipaddr)
               WinGetHandle($ipaddr & " - PuTTY", "")
               cmd()
               FileWrite($ipSuccess, $ipaddr & @CRLF)
            EndIf
         EndIf
   WEnd
EndIf

Func cmd()
   Sleep(3000)
   Send("conf t")
   Sleep(1000)
   Send("{ENTER}")
   Sleep(2000)
   Send("no username network")
   Sleep(1000)
   Send("{ENTER}")
   Sleep(2000)
   Send("username network privilege 15 secret password-here")
   Sleep(1000)
   Send("{ENTER}")
   Sleep(2000)
   Send("end")
   Sleep(1000)
   Send("{ENTER}")
   Sleep(2000)
   Send("copy run star")
   Sleep(1000)
   Send("{ENTER}")
   Send("{ENTER}")
   Sleep(4000)
   Send("exit")
   Send("{ENTER}")
   Sleep(3000)
EndFunc

FileClose($ipFile)
FileClose($ipFailed)
FileClose($pingFailed)
FileClose($ipSuccess)

 

 

 

 

putty-popup.PNG

Edited by moraist
More details
Link to comment
Share on other sites

  • Moderators

Moved to the appropriate forum, as the DEV forum specifically states:

Quote

Do not create AutoIt-related topics here, use AutoIt General Help and Support

@moraist Instead of putty and all the Sends :x have you tried plink?  Check the documentation on plink, specifically the -i parameter, for how to use a local file for your key.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...