PuTTY Download Secure Shell Access software. PuTTY is used for Telnet and as Secure shell Access client tool. Download PuTTY SSH Program. PuTTY Secure Shell Access Overview. PuTTY is one of the most used tool by Networking professionals. It is must have SSH (Secure Shell) Client software. This means you can remote access servers securely. PuTTY is a free and open source terminal emulator application which can act as a client for the SSH, Telnet, rlogin, and raw TCP computing protocols and as a serial console client.
I often find myself opening an SSH session to run the same single command. I have everything setup to login without entering a password (Via SSH Key-Based Auth), so I wondered if there was a way to create a shortcut or a batch file in Windows that would load PuTTY or a similar program, then fire off that command (and likely exit if result is good).
7 Answers
Use the commandline PuTTY version plink.exe
to initate a SSH connection to a host of choice. Use the -ssh
switch to connect with SSH. With the -m
switch you can include a command file:
You can download plink.exe
from here.
Last step would be to create a shortcut including plink.exe
with the desired parameters.
Check out the Plink documentation for other various parameters:Plink.exe documentation
To automate a command execution, use Plink (from PuTTY package), not PuTTY itself.
Plink accepts a command on its command line:
If you want to keep using PuTTY, you can use -m
switch to specify a command file (Plink supports the -m
switch too).
You can use putty configurations to achieve this.
Load putty and configure your session.
Enter the remote command that you'd like to run here:
Then, before clicking 'Open', go back to the 'Session' tab (at the top), and save your configuration.
Now, create a shortcut to putty.exe
, adding the -load
flag, for example:
Now, you can just click on the shortcut and it will load your session, executing your command.
AttieAttieIf you're using Windows 10, you might be interested to know that Microsoft reportedly has a beta of OpenSSH (client and server):
[…] go to “Manage Optional Features” then + “Add a feature”. You can then scroll down the list and find the OpenSSH Client (Beta) and OpenSSH Server (Beta) features in Windows. The idea of running another remote service on Windows can be daunting so we do not blame you if you do not want to install the server.
Once installed, you can simply fire up your command line and use the OpenSSH client by typing ssh followed by the command such as ssh ubuntu@someIP
.
Here is the current (as of November 28, 2017) ssh
command usage guide we are getting with the Windows OpenSSH Client:
If this works, you should be able to use ssh
like you would on a *Nix:
Just thought I'd insert the script I made to hopefully save some people hours of syntax and man page research
This batch assumes:
This is mostly useful for having a single script (such as updating an SSL certificate) across a range of machines
Here is complete batch file:
Putty To Ssh
You can also look at software such as mRemoteNG, MOBAxTerm or SecureCRT which will manage your SSH connections for you, this also links with the saved PuTTY sessions so you can apply a template to the session.
This is the final 'CMD' which I can just save on my FileServer and create a shortcut on my Desktop.
FreeSoftwareServersFreeSoftwareServers