X
    Categories: Linux

Epic way to connect to Linux server from Microsoft Excel.


Generally we kept all our inventory data in microsoft excel such as server ip, hostname & configuration etc. We generally do copy ip address from this excel , so that it can be pasted in putty.exe for connection. But what if don’t need to copy & paste ip details in excel, instead you just need to double click on the cell which has ip address for connection with the server. This post will guide you about how to connect to Linux server from Microsoft Excel.


Pre-requisite to connect to Linux server from Microsoft Excel

  1. Inventory with write access
  2. putty.exe

How to connect to Linux server from Microsoft Excel

1. Download the putty.

Please download putty.exe from the below links as per your architecture (32 Bit or 64 Bit)

putty.exe (the SSH and Telnet client itself)
Please keep the downloaded putty.exe under c:\ location.

 

2. Open the excel File.

Now open the microsoft excel ie your inventory where you have kept all your server details. For demo

purpose I have added only two ip address for connecting to Linux server as below:

3. Write Macro for automating the task.

Now we need to write sample macro so that it will call putty.exe upon double click event. For that Press “Alt+F11” within microsoft excel. Then new window will open as below :
 
Now Right click on Sheet1 (sheet in which you have all your ip details) and select View code option as below:
Now in the blank window on the right side paste below code, so that whenever you double click on ip column , putty.exe will be called with passing ip as a parameter.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Shell "C:\putty.exe -ssh " & ActiveCell, 1
    Cancel = True
End Sub

in case your username is same for all your connection use below code so that you only need to type password in the putty window.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Shell "C:\putty.exe -ssh -l root " & ActiveCell, 1
    Cancel = True
End Sub

In above we have used root as user for connecting automatically using putty.

4. Save the file with .xltm extension.

Now Press Ctrl+s for saving the file. Save this file as “Excel macro-Enabled Template” with “.xltm” extension.

5. Double click on IP column for connection with server.

Now you are almost done to connect to Linux server from Microsoft Excel. Just double click on the cell which has ip and putty will be called automatically passing IP as an parameter.

This How we double click on ip column to connect with server.

 

View Comments (1)

  • I was trying to use this procedure for sending a cell value to an external programe. But i am getting 'Run-time error '5' Invalid Procedure Call or Argument". i am almost on the verge of giving up as i am not able to fix it since the past few weeks!!

Related Post