PuTTY: How to start a SSH session from the command line
This tutorial assumes you have already opened your Windows command line
Now let’s learn how to start a SSH session from the command line
1) Type the path to Putty.exe here
2) Then type the connection type you wish to use (i.e. -ssh, -telnet, -rlogin, -raw)
4) Then type ‘@‘ followed by the server IP address
5) Finally, type the port number to connect to, then press <Enter>
A PuTTY session has now been opened
This is the end of the tutorial. You now know how to start a PuTTY session via command line
Anon June 9, 2014 at 6:34 pm
The correct answer is Putty cannot be run from the command line. This just opens a new window.
James Davey June 10, 2014 at 8:14 am
Yes, it does. But the command above opens that new window from the command line, as described.
deepanjan April 20, 2016 at 10:20 am
the command works fine but the new window is not maximized and the subsequent commands print lines without line breaks. how to solve these two problem
Corey Mahon April 28, 2016 at 10:06 am
Hi Deepanjan!
I’m sorry to hear you’re still having problems with running putty via command line. Please open a ticket with our support team through your backstage panel and also provide the exact command/one liner that you are using and our support team will be glad to take a look and see why this isn’t working properly. Thanks!
Jabba July 11, 2014 at 1:42 pm
This tutorial is not helpful – it assumes that the target server is insecure (requires no credentials / password to connect SSH).
James Davey July 11, 2014 at 2:37 pm
That is not the case at all. Following these steps, you will be prompted for your password.
czaro85 July 31, 2014 at 5:48 am
To skip prompt for password add “-pw [yourpassword]”.
putty.exe -ssh [email protected] 22 -pw yourpassword
rohitantil September 28, 2015 at 7:47 am
what if i wants to run some command also like ls -l
James Davey September 28, 2015 at 8:54 am
Hello,
You would be able to run that as soon as you connect. Simply type in the command and press Enter.
rohitantil September 28, 2015 at 1:26 pm
No i don,t want to run commands separately from my login . I want to run them with login command like
putty.exe -ssh [email protected] 22 -pw yourpassword mycommand
Can i do that ???
James Davey September 29, 2015 at 5:10 am
Hello,
Yes, you can do this using a -m flag after the password. Like this:
putty.exe -ssh [email protected] 22 -pw yourpassword -m yourcommand
Yagnik December 11, 2015 at 2:12 am
Hi James
putty.exe -ssh [email protected] 22 -pw yourpassword -m yourcommand
in above command -m flag will take the files as argument. type your commands in file and then execute.
Mikou March 18, 2016 at 6:35 am
Hi Yagnik
I tried putty.exe -ssh maintpct@11 22 -pw password -m flag command.txt
but is not working, do you know any other solution pliz ?
Tom Brown October 27, 2015 at 2:03 pm
The “plink.exe” executable is included with putty.exe. This executable is similar to the linux “ssh” command, even so far as to use the command prompt itself as the terminal. It also supports the “-C” option so you can quickly run a command on a remote server using:
plink.exe [email protected] -C “echo connection succeeded”
or
plink.exe [email protected] -C “ls -l”
Yasir February 19, 2016 at 4:02 pm
Thanks Tom its work, now I am able to run to do ssh via command prompt.
c:\>plink.exe 192.168.1.1 “then enter”
Jorge M April 8, 2016 at 10:54 pm
These commands worked well in windows 10 as well as Ubuntu desktop and Ubuntu server. Plink also allows me to run a task in windows from Linux. unfortunately I only was able to run commands that does not require administrative privileges.
Corey Mahon April 12, 2016 at 8:51 am
Thank you for the update Jorge! I’m glad this worked out for you!
Ben April 17, 2016 at 3:27 pm
You can use the following command to get administrative priviliges:
echo yourpassword | sudo -S yourcommand
For example:
plink.exe [email protected] -pw yourpassword -C “echo yourpassword | sudo -S yourcommand”
Abhishek Kumar May 30, 2016 at 6:16 am
Was very helpful for me.
Thanks,
Abhishek
Neta Sharon June 7, 2016 at 4:04 am
Hi,
How can I use the automation above in case that my machine’s password is empty?
Means, manually, when I open the putty with my username, I just press enter.
Now i’m trying to write a catch script for the automation above and I would like to know how to express this function in the script.
Thanks a lot.
Corey Mahon June 23, 2016 at 8:46 am
Hi Neta! All SSH accounts on our servers do require a password to log in, so, your machine would not have an empty password. For scripting these connections to be automatic, there are several ways you can do this. You can either code the password into your script so it is sent to the server when the password is requested or, you can set up matching private keys which would remove the password requirement and automatically log you in when you attempt to connect via ssh. You can read more about setting up keys here:
http://kb.site5.com/shell-access-ssh/putty/how-to-generate-ssh-keys-and-connect-to-your-account-with-putty/ (Windows)
http://kb.site5.com/shell-access-ssh/how-to-generate-ssh-keys-and-login-to-your-account-with-ssh/ (Mac & Linux)
Kostas July 12, 2016 at 12:31 pm
Very interesting, thank you.
Corey Mahon July 18, 2016 at 12:43 pm
You’re quite welcome Kostas! If you run into any problems, please don’t hesitate to reach out to our support team. We’re always glad to help out!