ganesh_6663
New Member
- Joined
- Jul 15, 2021
- Messages
- 33
- Office Version
- 2016
- Platform
- Windows
Crated small tool to login Myserver using putty , but first need to login Jump server from Jump server we can login Myserver .
Required Myserver ping status on my tool , if ping is OK then login to server or "PING NOT OK" msg and stop micro.
login tool download link..........
Required Myserver ping status on my tool , if ping is OK then login to server or "PING NOT OK" msg and stop micro.
login tool download link..........
VBA Code:
Sub PUTTYSM()
Dim PuttyPID As Double
Dim PuttyHwnd As LongPtr
Dim serverName As String
Dim username As String
Dim password As String
Dim enbpass As String
Dim Jumpserver As Variant
Dim myserver As Variant
myserver = UserForm1.Reg2.Value
Jumpserver = UserForm1.Reg3.Value
username = "demo"
password = "password"
mainserverpass = "password"
PuttyPID = Shell("D:\putty.exe -ssh " & Jumpserver, vbNormalFocus) 'CHANGE PATH TO .EXE
PuttyHwnd = GetWindowHandle(CLng(PuttyPID))
If PuttyHwnd <> 0 Then
'Login jump server
Application.Wait DateAdd("s", 2, Now)
SendChars PuttyHwnd, username & vbCr
Application.Wait DateAdd("s", 2, Now)
SendChars PuttyHwnd, password & vbCr
'Login main server
Application.Wait DateAdd("s", 1, Now)
SendChars PuttyHwnd, "ssh demo@" & myserver & vbCr
Application.Wait DateAdd("s", 1, Now)
SendChars PuttyHwnd, mainserverpass & vbCr
End If
End Sub
--------------------------------------------------------------------------------------------------
Sub PUTTYSMPING()
Dim PuttyPID As Double
Dim PuttyHwnd As LongPtr
Dim serverName As String
Dim username As String
Dim password As String
Dim enbpass As String
Dim Jumpserver As Variant
Dim myserver As Variant
myserver = UserForm1.Reg2.Value
Jumpserver = UserForm1.Reg3.Value
username = "demo"
password = "password"
PuttyPID = Shell("D:\putty.exe -ssh " & Jumpserver, vbNormalFocus) 'CHANGE PATH TO .EXE
PuttyHwnd = GetWindowHandle(CLng(PuttyPID))
If PuttyHwnd <> 0 Then
'Login jump server
Application.Wait DateAdd("s", 2, Now)
SendChars PuttyHwnd, username & vbCr
Application.Wait DateAdd("s", 2, Now)
SendChars PuttyHwnd, password & vbCr
'Ping main server
Application.Wait DateAdd("s", 1, Now)
SendChars PuttyHwnd, "ping " & myserver & vbCr
Application.Wait DateAdd("s", 1, Now)
End If
End Sub