Archived Forum PostQuestion:
I am trying to connect to an Android dropbear SSH Server. The initial connection and authentication work fine, however when I try to open a session channel the channel number is returned as -1.
int channelNum = mSSH->OpenSessionChannel();
if (channelNum < 0)
{
char buffer[2048];
sprintf_s(buffer, 2048, "%s\nError: %s", mSSH->lastErrorText(), mSSH->channelOpenFailReason());
LOGW(buffer);
return;
}
The last error text is
ChilkatLog: OpenSessionChannel:
DllDate: Jun 13 2016
ChilkatVersion: 9.5.0.58
UnlockPrefix: Anything for 30-day trial
Architecture: Little Endian; 32-bit
Language: Visual C++ 12.0 (32-bit)
VerboseLogging: 0
openSessionChannel:
sshTransportOpenChannel:
channelType: session
clientChannel: 0
clientInitialWindowSize: 327680
clientMaxPacketSize: 8192
Sent open channel request
Unexpected message type received in response to open channel
request.
messageType: 51
--sshTransportOpenChannel
channelNum: -1
--openSessionChannel
retval: -1 --OpenSessionChannel
--ChilkatLog
How do I fix this?
Thanks
Here are the lags from the connect and authenticate. All seems OK.
Connected
ChilkatLog:
Connect_Ssh:
DllDate: Jun 13 2016
ChilkatVersion: 9.5.0.58
UnlockPrefix: Anything for 30-day trial
Architecture: Little Endian; 32-bit
Language: Visual C++ 12.0 (32-bit)
VerboseLogging: 0
connectInner:
hostname: 192.168.6.36
port: 22
sshConnect:
Established TCP/IP connection with SSH server
--sshConnect
sshSetupConnection:
clientIdentifier: SSH-2.0-PuTTY_Release_0.66
Sending client identifier...
Done sending client identifier.
Reading server version...
initialDataFromSshServer: SSH-2.0-dropbear_2015.67
serverVersion: SSH-2.0-dropbear_2015.67
KeyExchangeAlgs:
algorithm: curve25519-sha256@libssh.org
algorithm: ecdh-sha2-nistp521
algorithm: ecdh-sha2-nistp384
algorithm: ecdh-sha2-nistp256
algorithm: diffie-hellman-group14-sha1
algorithm: diffie-hellman-group1-sha1
algorithm: kexguess2@matt.ucc.asn.au
--KeyExchangeAlgs
HostKeyAlgs:
algorithm: ecdsa-sha2-nistp521
algorithm: ssh-rsa
--HostKeyAlgs
EncCS:
algorithm: aes128-ctr
algorithm: aes256-ctr
algorithm: aes128-cbc
algorithm: aes256-cbc
algorithm: 3des-ctr
algorithm: 3des-cbc
--EncCS
EncSC:
algorithm: aes128-ctr
algorithm: aes256-ctr
algorithm: aes128-cbc
algorithm: aes256-cbc
algorithm: 3des-ctr
algorithm: 3des-cbc
--EncSC
MacCS:
algorithm: hmac-sha2-256
algorithm: hmac-sha2-512
algorithm: hmac-sha1-96
algorithm: hmac-sha1
algorithm: hmac-md5
--MacCS
MacSC:
algorithm: hmac-sha2-256
algorithm: hmac-sha2-512
algorithm: hmac-sha1-96
algorithm: hmac-sha1
algorithm: hmac-md5
--MacSC
CompCS:
algorithm: none
--CompCS
CompSC:
algorithm: none
--CompSC
ChosenIncomingEncryption: aes256-ctr
ChosenOutgoingEncryptoin: aes256-ctr
ChosenIncomingMac: hmac-sha2-256
ChosenOutgoingMac: hmac-sha2-256
ChosenIncomingCompression: none
ChosenOutgoingCompression: none
ChosenKexAlgorithm: diffie-hellman-group1-sha1
ChosenHostKeyAlgorithm: ssh-rsa
Using SHA-1 for Key Exchange Hash
RSA host key parsed successfully.
Sending newkeys to server...
Expecting newkeys from server...
SSH Key Exchange Success.
installNewKeys:
m_isRekey: 0
No outgoing compression.
No incoming compression.
Outgoing encryption is now AES 256 CTR
outgoingMac: SHA256
--installNewKeys
--sshSetupConnection
socketOptions:
SO_SNDBUF: 262144
SO_RCVBUF: 4194304
TCP_NODELAY: 1
SO_KEEPALIVE: 0
--socketOptions
--connectInner
Success.
--Connect_Ssh
--ChilkatLog
Authenticated
ChilkatLog:
AuthenticatePw:
DllDate: Jun 13 2016
ChilkatVersion: 9.5.0.58
UnlockPrefix: Anything for 30-day trial
Architecture: Little Endian; 32-bit
Language: Visual C++ 12.0 (32-bit)
VerboseLogging: 0
SshVersion: SSH-2.0-dropbear_2015.67
sshAuthenticatePw:
requestUserAuthService:
sendServiceRequest:
svcName: ssh-userauth
SentServiceReq: ssh-userauth
--sendServiceRequest
ssh-userauth service accepted.
--requestUserAuthService
[SSH] Received USERAUTH_BANNER
AuthMethods: publickey,password
passwordAuth:
Sent login/password
Password authentication successful.
--passwordAuth
--sshAuthenticatePw
Success.
--AuthenticatePw
--ChilkatLog
ChilkatLog:
OpenSessionChannel:
DllDate: Jun 13 2016
ChilkatVersion: 9.5.0.58
UnlockPrefix: Anything for 30-day trial
Architecture: Little Endian; 32-bit
Language: Visual C++ 12.0 (32-bit)
VerboseLogging: 0
openSessionChannel:
sshTransportOpenChannel:
channelType: session
clientChannel: 0
clientInitialWindowSize: 327680
clientMaxPacketSize: 8192
Sent open channel request
Unexpected message type received in response to open channel request.
messageType: 51
--sshTransportOpenChannel
channelNum: -1
--openSessionChannel
retval: -1
--OpenSessionChannel
--ChilkatLog
Error:
So I found the fix for this was to authenticate using a private key. There seems to be a bug in the AuthenticatePw code, as it was saying that the authentication succeeded.
The message type 51 is a SSH2_MSG_USERAUTH_FAILURE. Check the LastErrorText's for calls leading up to the call to OpenSshChannel to see if that gives any clues.