Site5 - Built For Designers & Developers MENU
Home  ›  Shell Access (SSH)  ›  PuTTY  ›  PuTTY: How to start a SSH session from the command line

PuTTY: How to start a SSH session from the command line

23 Comments

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)

3) Type the username…

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

Still have a question? Or need help?
If you need technical support with your account, please email us or chat live with a representative.

23 Comments

  • The correct answer is Putty cannot be run from the command line. This just opens a new window.

    • Yes, it does. But the command above opens that new window from the command line, as described.

      • 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

        • 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!

  • This tutorial is not helpful – it assumes that the target server is insecure (requires no credentials / password to connect SSH).

    • That is not the case at all. Following these steps, you will be prompted for your password.

    • To skip prompt for password add “-pw [yourpassword]”.
      putty.exe -ssh [email protected] 22 -pw yourpassword

      • what if i wants to run some command also like ls -l

        • Hello,

          You would be able to run that as soon as you connect. Simply type in the command and press Enter.

          • 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 ???

            • 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

              • 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.

                • 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 ?

  • 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”

  • 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”

  • 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.

    • Thank you for the update Jorge! I’m glad this worked out for you!

    • 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”

  • Was very helpful for me.
    Thanks,
    Abhishek

  • 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.

  • Very interesting, thank you.

    • 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!

Money Back Guarantees