0
votes

I am trying to use plink(Putty link) to connect to test servers using a batch file so as to avoid any user prompts and executing shell scripts. But it is pausing by showing a user interactive prompt after logging in with username and password provided which I don't want.

Please provide any suggestion for why this is happening or if I need to change any settings in the configuration to make this work.

Below is the log for the same. I am expecting it to execute a shell script after this step before which it gets stopped and plink puts me in an interactive shell

D:\>plink -v -ssh [email protected] –pw XXXXX
Looking up host "[email protected]"
Connecting to xxx.xx.xxx.xx port 22
Server version: SSH-2.0-OpenSSH_5.1
Using SSH protocol version 2
We claim version: SSH-2.0-PuTTY_Release_0.63
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-256
Host key fingerprint is:
ssh-rsa 1024 a5:c3:96:57:53:7c:72:06:8d:86:09:76:27:3e:18:8d
Initialised AES-256 SDCTR client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised AES-256 SDCTR server->client encryption
Initialised HMAC-SHA1 server->client MAC algorithm
Using username "xxx".

Attempting keyboard-interactive authentication
Access granted
Opening session as main channel
Opened main channel
Allocated pty (ospeed 38400bps, ispeed 38400bps)
Started a shell/command
Last login: Wed Mar  5 09:56:41 2014 from 10.34.39.22


←[?1034hxxxxavu2:←]2;xxx@xxxxavu2~ >
2

2 Answers

0
votes

It's giving you an interactive shell because you are not actually giving it a command to execute after connecting. Enclose your command in quotes, eg:

D:\>plink -v [email protected] -pw XXXXX "df -h"
0
votes

When using SSH, upon first connection you are required to verify a service host key in order to make a connection.

Through plink, the command line will generate a prompt, asking the user to "accept service host key? (y/n)".

Step 1: Fix the "Keyboard Interactive Authentication prompts from server"

Follow the URL instruction and Deselect the "Attempt keyboard Interactive auth (SSH-2) in your putty.

https://support.linuxacademy.com/hc/en-us/articles/360027730172-How-Can-I-Copy-and-Paste-into-Putty-on-Windows

Step 2: Below is the commands will fix the "verify a service host key" for every Linux server first SSH connection using plink.

 echo yes| C:\PuTTY\plink.exe [email protected] -pw *************** date 

Step 3: Now you can immediately ran your next scripts like "server uptime checks" or "monitoring agent restart" using plink with -batch option (disable all interactive prompts)

C:\PuTTY\plink.exe -batch [email protected] -pw *************** -m C:\uptime_linux.sh 
C:\PuTTY\plink.exe -batch [email protected] -pw *************** -m C:\monitoring-agent-check_linux.sh 

Above mentioned information's 100% will help you to automate the linux tasks using plink utility.