You may not need Putty anymore if you try this...
This tutorial is for Windows users who want a neater way of connecting to their servers other than using Putty.
3 min read
If you're familiar with managing Virtual machine instances and servers on GCP, AWS, DigitalOcean and others, you most likely already know about SSH.
Usually, you'd create an SSH key pair, save the private key on your machine and store the public key in the authorized_keys file of your Linux server. Having these keys make it easy for you to be authenticated without a password when you try to access your server remotely.
For those who use Linux and Mac, you usually have the SSH utility already installed. But when you're in the Windows ecosystem, a lot of things aren't handed to you on a silver platter.
Most tutorials would teach you to install an app called Putty and use it when you need to connect to your server but behold... I teach you a new way today.
First, you need a Windows machine. Connected to the internet.
Next, you need the
sshutility. So go ahead and open command prompt and type
If you have it already, you should get something like this:
If you do not see that, try to install or enable SSH.
Create a custom command
Now make sure you have your private key to the server. If you already had Putty, then it means you already had a private key stored somewhere on your computer. You just need to locate it. Make sure to use the original private key, not Putty's .ppk format.
Now, before I proceed, I wish to give credit to this StackOverflow answer for guiding me in the right direction.
Let's proceed. Please note that you can do the following through Windows Explorer if you wish.
Open cmd.exe (Command Prompt)
Navigate to your user directory. For example,
cd C:\Users\john. In my case, the username is "user", but I will stick with "john" for this post in order not to confuse anyone.
Run the following one after the other to create and populate a file where we'd house our commands. You can name it anything you want, but the extension must be cmd:
echo @echo off >> init.cmd
echo doskey open-my-server=ssh -i "C:\Users\john\.ssh\id_secret_key" firstname.lastname@example.org >> init.cmd
make sure to replace xxx.xxx.xxx.xxx with your server's IP address. Also, the -i flag points to our identity file (private key).
Verify the content of the new file with
Make your script automatically available to Command Prompt by adding the path to your file in the registry:
reg add "HKCU\Software\Microsoft\Command Processor" /v AutoRun /t REG_EXPAND_SZ /d "%"USERPROFILE"%\commands\init.cmd" /f
Restart command prompt
Now you can run
open-my-serverand it should just connect in the terminal beautifully.
So that's it! I hope you enjoyed this. Your comments, questions and feedback are most welcome!