user9278626
user9278626

Reputation: 11

Launching putty with username and password mentioned in the Excel sheet

I have list of servers in the excel sheet with username and password in 6th row and J,K column. I need a macro code to launch multiple putty as per the IP address/hostname mentioned in the A column and also the putty to be login automatically with the username and password mentioned in the excel.

Can anyone please help me? Here my code:

Sub PUTTY()

    i = 6
    While (ActiveSheet.Cells(i, 1) <> "")
'Retrieve IP address
    StrCompAddress = ActiveSheet.Cells(i, 1)
    i = i + 1
    Wend
    j = 6
    While (ActiveSheet.Cells(i, 10) <> "")
    UserName = ActiveSheet.Cells(j, 10)
    Wend
    k = 6
    While (ActiveSheet.Cells(i, 11) <> "")
    password = ActiveSheet.Cells(j, 10)
    Wend
 Dim RetVal
 RetVal = Shell("C:\Users\Public\Desktop\putty.exe " & StrCompAddress & " " & UserName & " " & password & " ")
   End Sub

By using this code I'm just able to launch putty, but unable to login automatically with the username and password :-(

Upvotes: 1

Views: 2051

Answers (1)

Andrew Femin
Andrew Femin

Reputation: 43

Use the below line:

RetVal = Shell("C:\Users\Public\Desktop\putty.exe " & UserName & "@" & StrCompAddress & " -pw " & password)

The standard command is:

C:\Program Files\PuTTY\putty.exe user@serverName -pw password

In some versions of PuTTY, this could also be:

C:\Program Files\PuTTY\putty.exe serverName -l mylogin -pw mypassword

Upvotes: 2

Related Questions