open ssh connection with option -hostkey like a parameter

Advertisement

ivarodr
Joined:
Posts:
6
Location:
Spain

open ssh connection with option -hostkey like a parameter

Hi,
i am doing a .cmd file to automate a ssh connection to a server and when i use the option -hostkey in the open command i don't have the expected results because i get the message "i don't understand the server key....".

This is part of my .cmd file:
cd C:\Program Files\WinSCP
start winscp.com /command "option batch on" "option confirm off" "open %2:%3@%1 -hostkey=%6"
I call this .cmd from vbs.

I am sure that the problem is located in parameter %6 and i think that the problem comes from the type of the param because is like it didn't have been recognised like a String.

Please help.
THX.

Reply with quote E-mail

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,515
Location:
Prague, Czechia

Re: open ssh connection with option -hostkey like a parameter

Can you post a log file? The error message does not look familiar to me.

Reply with quote

ivarodr
Joined:
Posts:
6
Location:
Spain

Excuse me, it has been my error in the definition of the error message.

The complete error message is:
I don't understand the server key. There is no guarantee of that remote "team" is really who you think it is.

The digital rsa2 fingerprint of the server key is: ssh-rsa 2048 ...........................

If you meet this "team" you have to answer yes, .....
The server key doesn't have been verified!!!

Escuse my poor English.
THX.

Reply with quote E-mail

ivarodr
Joined:
Posts:
6
Location:
Spain

[quote :) ="prikryl"]Can you post a log file?[/quote]
. 2010-06-10 15:19:21.893 --------------------------------------------------------------------------
. 2010-06-10 15:19:21.894 WinSCP Version 4.2.7 (Build 758) (OS 6.1.7600)
. 2010-06-10 15:19:21.894 Login time: jueves, 10 de junio de 2010 15:19:21
. 2010-06-10 15:19:21.894 --------------------------------------------------------------------------
. 2010-06-10 15:19:21.895 Session name: sgbe6
. 2010-06-10 15:19:21.895 Host name: sgbe6 (Port: 22)
. 2010-06-10 15:19:21.895 User name: (Password: No, Key file: No)
. 2010-06-10 15:19:21.896 Tunnel: No
. 2010-06-10 15:19:21.896 Transfer Protocol: SFTP (SCP)
. 2010-06-10 15:19:21.896 Ping type: -, Ping interval: 30 sec; Timeout: 6000 sec
. 2010-06-10 15:19:21.897 Proxy: none
. 2010-06-10 15:19:21.897 SSH protocol version: 2; Compression: No
. 2010-06-10 15:19:21.897 Bypass authentication: No
. 2010-06-10 15:19:21.897 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2010-06-10 15:19:21.898 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2010-06-10 15:19:21.898 SSH Bugs: -,-,-,-,-,-,-,-,-
. 2010-06-10 15:19:21.898 SFTP Bugs: -,-
. 2010-06-10 15:19:21.898 Return code variable: Autodetect; Lookup user groups: Yes
. 2010-06-10 15:19:21.898 Shell: default, EOL: 1
. 2010-06-10 15:19:21.898 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2010-06-10 15:19:21.899 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2010-06-10 15:19:21.899 Local directory: default, Remote directory: home, Update: No, Cache: Yes
. 2010-06-10 15:19:21.899 Cache directory changes: Yes, Permanent: Yes
. 2010-06-10 15:19:21.899 DST mode: 0
. 2010-06-10 15:19:21.899 --------------------------------------------------------------------------
. 2010-06-10 15:19:22.126 Looking up host "sgbe6"
. 2010-06-10 15:19:22.131 Connecting to 10.95.15.20 port 22
. 2010-06-10 15:19:22.189 Server version: SSH-2.0-OpenSSH_4.6
. 2010-06-10 15:19:22.189 Using SSH protocol version 2
. 2010-06-10 15:19:22.189 We claim version: SSH-2.0-WinSCP_release_4.2.7
. 2010-06-10 15:19:22.206 Doing Diffie-Hellman group exchange
. 2010-06-10 15:19:22.244 Doing Diffie-Hellman key exchange with hash SHA-1
. 2010-06-10 15:19:22.618 Asking user:
. 2010-06-10 15:19:22.618 The server's host key was not found in the cache. You have no guarantee that the server is the computer you think it is.
. 2010-06-10 15:19:22.618
. 2010-06-10 15:19:22.618 The server's rsa2 key fingerprint is:
. 2010-06-10 15:19:22.618 ssh-rsa 2048 f7.......
. 2010-06-10 15:19:22.619
. 2010-06-10 15:19:22.619 If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel.
. 2010-06-10 15:19:22.619
. 2010-06-10 15:19:22.619 Continue connecting and add host key to the cache? ()
. 2010-06-10 15:19:27.574 Attempt to close connection due to fatal exception:
* 2010-06-10 15:19:27.575 Host key wasn't verified!
. 2010-06-10 15:19:27.575 Closing connection.
. 2010-06-10 15:19:27.575 Sending special code: 12
* 2010-06-10 15:19:27.625 (ESshFatal) Host key wasn't verified!
* 2010-06-10 15:19:27.626 Authentication failed.

Reply with quote E-mail

Advertisement

ivarodr
Joined:
Posts:
6
Location:
Spain

I get this error

I pass to %6 a vbs variable with the value of the RSAKey as String.
I get this error message if i pass the rsa key like a parametre of my script but i don't get this error message if a do the same action in a winscp console.
This is my vbs code:
Dim ws, oExec....
......
RSAkey="ssh-rsa 2048 ....."
set ws = CreateObject("WScript.Shell")
Set oExec = ws.Exec(PathScript&" "&serverIP&" "&user&" "&pass&" "&node&" "&country&" "&RSAkey)
Dim output
output=""
Do Until oExec.stdOut.AtEndOfStream
output=output&oExec.stdOut.Read(1)
Loop
.....

An interesting thing is that if a execute my script from cmd.exe passing the same parametres (with an unique difference what is pass the RSAKey like a literal String , not saving it in a variable) adding "%6" i don't get the error message, i am going crazy.

Reply with quote E-mail

martin
Site Admin
martin avatar

Re: I get this error

You need to enclose the hostkey into double-quotes. That's probably also your difference between calling using variable and literal string (where you probably add the double-quotes).

Reply with quote

Advertisement

You can post new topics in this forum