Recieving data from ssh login to Mikrotik host fa (General questions)
Hi supportforum,
we are using the following software:
wodSSH.Net v. 2.2.1.50
.Net Framework 2.0 / Visual Basic 2005 Express Edt.
Mikrotik RouterOS 2.9.18 (www.mikrotik.com)
The task is to connect to the Mikrotik, execute commands and get the
result back. Example with PuTTY:
[code]
login as: admin
admin@xxx.xxx.xxx.xxx password:
MMM MMM KKK TTTTTTTTTTT KKK
MMMM MMMM KKK TTTTTTTTTTT KKK
MMM MMMM MMM III KKK KKK RRRRRR OOOOOO TTT III KKK KKK
MMM MM MMM III KKKKK RRR RRR OOO OOO TTT III KKKKK
MMM MMM III KKK KKK RRRRRR OOO OOO TTT III KKK KKK
MMM MMM III KKK KKK RRR RRR OOOOOO TTT III KKK KKK
MikroTik RouterOS 2.9.18 (c) 1999-2006 http://www.mikrotik.com/
Terminal xterm detected, using multiline input mode
[admin@Hotspot] > /system clock print
time: 15:43:26
date: apr/05/2006
time-zone: +01:00
dst-active: no
[admin@Hotspot] >
[/code]
I used the following code:
[code]
Ssh.Login = admin
Ssh.Password = xxxxxxxx
Ssh.Encryption = WeOnlyDo.Client.SSH.EncryptionMethods.Auto
Ssh.Protocol = WeOnlyDo.Client.SSH.SupportedProtocols.SSHAuto
Ssh.Blocking = True
Ssh.Prompt = regex:[[a-z]+@[a-zA-z]+][a-zA-z0-9 ]+> $
Ssh.Connect( xxx.xxx.xxx.xxx )
Ssh.WaitFor( regex:[[a-z]+@[a-zA-z]+][a-zA-z0-9 ]+> $ )
Ssh.Receive()
result = Ssh.Execute( /system clock print & vbCrLf, regex:[[a-z]+@[a-zA-z]+][a-zA-z0-9 ]+> $ )
Ssh.Receive()
Console.Write(result)
[/code]
execution of these lines returns
[code]
[admin@Hotspot] >
[admin@Hotspot] >
[/code]
Mikrotik uses the following SSH server:
[code]
[root@telefonzelle ~]# ssh -2 -v admin@xxx.xxx.xxx.xxx
OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to xxx.xxx.xxx.xxx [xxx.xxx.xxx.xxx] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: Remote protocol version 1.99, remote software version OpenSSH_2.3.0_Mikrotik_v2.9
debug1: match: OpenSSH_2.3.0_Mikrotik_v2.9 pat OpenSSH_2.3.0*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.9p1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client 3des-cbc hmac-md5 none
debug1: kex: client->server 3des-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST_OLD(2048) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'xxx.xxx.xxx.xxx' is known and matches the DSA host key.
debug1: Found key in /root/.ssh/known_hosts:2
debug1: ssh_dss_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Next authentication method: password
admin@xxx.xxx.xxx.xxx's password:
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
MMM MMM KKK TTTTTTTTTTT KKK
MMMM MMMM KKK TTTTTTTTTTT KKK
MMM MMMM MMM III KKK KKK RRRRRR OOOOOO TTT III KKK KKK
MMM MM MMM III KKKKK RRR RRR OOO OOO TTT III KKKKK
MMM MMM III KKK KKK RRRRRR OOO O