learn more...Using PuTTY from the command line will create an SSH interactive session. This may not be what we want if for example we need to remain at the Windows command line or we want to issue an SSH command from within a script. In order to satisfy these types of needs, PuTTY provides a tool called Plink. Plink is a command line tool that will allow you to log in to a remote machine using SSH and either create an SSH session or execute a command, all from the command line and without opening another window. Plink comes with many command line options that can be accessed with the –h option: C:\>plink -h However, you will probably never use many of the options available. The most common options you will likely use are as follows: plink [ -v] [ -batch] [-l user] [-load session] [user@]hostname[command] where:
If an interactive prompt appears during connection, Plink will fail the connection rather than hang. -load session = the name of the saved PuTTY session to load. This is used as an alternative to giving Plink a user and hostname with which to connect. To run Plink: If you are not already at a Windows command prompt, click on the Start Menu and select Run. In the field provided, type in cmd if you are running Windows NT/2000/XP or command if you are running Windows 9x/ME and click on the OK button. This will give you a Windows command prompt. From the Windows command prompt, issue the plink command. For example, to establish a connection to remote host server.example.com as user sshuser: C:\>plink -ssh sshuser@server.example.com In this case, Plink opens up an SSH session from the local machine to the remote host just as PuTTY would. Note Running an SSH connection from within a Windows command prompt may result in undesirable effects, due to the fact that the Windows command prompt does not know how to handle the control codes from the different terminal types that are set up in a remote UNIX shell session. Therefore, running commands such as clear may cause garbage to display on the screen. If possible, use PuTTY to open a shell session to a remote machine. Plink can also be used to create an SSH session and execute a command or script on the remote machine from the Windows command line. For example, to connect to remote host server.example.com as user sshuser to run the command uname –a: C:\>plink -ssh sshuser@server.example.com "uname -a" C:\> As you can see, Plink connects to the remote machine, is prompted for authentication, and upon successful authentication executes the command provided and displays any output on the local machine. |
||||||
Disclaimer
1) E-articles is not responsible for the information contained by this article as well for any and all copyright infringements by authors and writers. E-articles is a free information resource. If you suspect this article for any copyright infringement, please read the terms of service and contact us to investigate the problem.
2) E-articles is not responsible for inaccuracies, falsehoods, or any other types of misinformation this article may contain and will not be liable for any loss or damage suffered by a user through the user's reliance on the information gained here. link to this article |