The easiest way to get these into the registry is using the kh2reg.py Python script in the ‘contrib’ directory of the PuTTy project.
#Powershell putty ssh windows#
This might not bother you, but if you want to pre-populate the known host keys and avoid this alert, these keys are stored in the Windows registry at “KHCU\Software\SimonTatham\Putty\SshHostKeys”. You might notice that the first time you open a session to one of these hosts, you get a GUI popup that asks you to accept the host key. You can always formulate your own template settings by modifying a session in the PuTTY GUI, then using regedit.exe to export the registry key from “KHCU\Software\SimonTatham\Putty\Sessions\” Populate host keys (optional) My template.reg is very basic with a 80×45 terminal size, 10k line scrollback, and 30 second keepalives. Close PuTTy and reopen it, and now you should see all your host sessions listed. This will go through each line in your “puttyhosts.txt” and use the “template.reg” as a blueprint for creating registry files that are then imported using the standard Windows utility reg.exe. Populate PuTTy session listĭownload createPuttySessions.ps1 and template.reg from my github project and put it into the same directory as the “puttyhosts.txt” you created in the last step.ĭrop down to the command line, and run: powershell -executionpolicy bypass. Here is an example: myhost,192.168.1.10Ĭreate a text file named “puttyhosts.txt”, and whether you populate this text file manually, or use a script that discovers each host is completely up to you. The name is what PuTTY will show in its list, while the second field is the FQDN or the IP address it will actually use to connect to the remote host.
![powershell putty ssh powershell putty ssh](https://namecheap.simplekb.com/SiteContents/2-7C22D5236A4543EB827F3BD8936E153E/media/PowerShell1.0.png)
The format we will use is a text file where each line represents a host, and each line has the format: , The first thing we need is a list of the hosts that we want added to Putty.
#Powershell putty ssh install#
Download and install VC runtime Update 1 with all defaults.ĭownload and install Python3 for Windows with all defaults. You must use at least Update 1 to satisfy all dependencies. Python 3 on Windows has a dependency on the Visual C++ Runtime 2015. Download and install Git for Windows with all defaults. Git for Windows contains a minimal bash and ssh-keyscan which is used to generate the known_hosts format. Prerequisitesĭownload and install PuTTY with all defaults. You can simply export your registry branch and have them import it. Once you have all these loaded into your registry, it is not necessary to have your co-workers run these same steps if they want the same list.
![powershell putty ssh powershell putty ssh](https://www.peppercrew.nl/wp-content/uploads/2018/01/image-5.png)
This will be done using a Python script that can convert a file in the known_hosts format to a registry file.
![powershell putty ssh powershell putty ssh](https://www.peppercrew.nl/wp-content/uploads/2018/01/image.png)
![powershell putty ssh powershell putty ssh](https://alifurkan.org/content/public/upload/windows-ssh-baglantisi-kurma_0_o.png)
This would suffice to create a pre-populated list, but we will take it one step further and also populate “KHCU\Software\SimonTatham\Putty\SshHostKeys” so that the host keys are preloaded and PuTTY will not have to prompt us to accept the key on the first access. We will use a template registry file and Windows Powershell to create these in bulk. Ultimately, what shows up in the PuTTy session list is the list of registry entries at “KHCU\Software\SimonTatham\Putty\Sessions”.
#Powershell putty ssh how to#
In this article, I will show you how to generate these session definitions for a bulk set of hosts, preloaded for a Windows PuTTy installation. but creating each session definition by hand is time consuming. And creating a saved session definition is extremely helpful so I can get the right window size, scrollback, keep alives, color scheme, etc. Putty is one of the first tools I install on any host or jumpbox.