3
0
On Windows I use PuTTY to log in to a remote server via SSH. I want to use a batch script to SSH to the remote server using PuTTY. The server is running a Linux-based OS.
I used the below command to do this:
start C:\Windows\System32\putty.exe -ssh server_name -l pankmish -pw wxyz
However I got the following error:
unable to connect to remote host
If I use this command instead:
start C:\Windows\System32\putty.exe -ssh server_name -l user_name
Everything works well and I get a PuTTY window with username "user_name" in it. If I provide the correct password I am able to connect to the server. However via a batch script I am not able to provide the password when prompted.
How can I solve this?
Might I suggest, that you should be using
SSH key-based authentication
vs Passwords, it will be more secure and easier to configure. (Though the most secure is Key-Based auth w/ password!) – FreeSoftwareServers – 2017-12-21T12:32:51.340See my related question here >> https://superuser.com/questions/1278434/create-a-batch-file-or-shortcut-to-putty-ssh-that-opens-a-session-and-runs-a-c/1279087#1279087
– FreeSoftwareServers – 2017-12-21T12:33:52.730did you use Plink to connect putty and remote server. – None – 2014-04-01T18:47:43.547
On Windows, you can create a Powershell script (using the ssh.net library) to connect to a remote server by SSH and automate a task. See http://www.powershelladmin.com/wiki/SSH_from_PowerShell_using_the_SSH.NET_library
– None – 2014-04-01T18:47:49.117I tried using Plink also to connect putty and remote server, but error was same. – pankmish – 2014-04-01T18:49:30.557
I think error is coming because password prompt is coming in next line of user name prompt. so please suggest me any example batch script to give password when it is prompted. – pankmish – 2014-04-01T18:51:32.513
I tried same command->> start C:\Windows\System32\putty.exe -ssh server_name -l user -pw %1; and provided password from command line and it worked fine. – pankmish – 2014-04-03T14:13:49.003