From c64f49a060f0ebc2347ea719981377eed0ea558d Mon Sep 17 00:00:00 2001 From: Christian Diaconu Date: Tue, 15 May 2018 20:41:42 +0100 Subject: [PATCH] Fixing an SSH communication issue Fixing the issue when the "env" RequestType is sent by the client, resulting in a client disconnection by the server. --- GitCandy/Ssh/Services/ConnectionService.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/GitCandy/Ssh/Services/ConnectionService.cs b/GitCandy/Ssh/Services/ConnectionService.cs index 88d932d..4a93048 100644 --- a/GitCandy/Ssh/Services/ConnectionService.cs +++ b/GitCandy/Ssh/Services/ConnectionService.cs @@ -61,6 +61,21 @@ private void HandleMessage(ChannelOpenMessage message) } } + private bool IsRequestTypeTolerated(ChannelRequestMessage message) + { + if (message == null) + return (false); + + switch (message.RequestType) + { + // Occured on Ubuntu -> "SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2" + case "env": + return (true); + default: + return (false); + } + } + private void HandleMessage(ChannelRequestMessage message) { switch (message.RequestType) @@ -75,7 +90,11 @@ private void HandleMessage(ChannelRequestMessage message) { RecipientChannel = FindChannelByServerId(message.RecipientChannel).ClientChannelId }); - throw new SshConnectionException(string.Format("Unknown request type: {0}.", message.RequestType)); + + if (!IsRequestTypeTolerated(message)) + throw new SshConnectionException(string.Format("Unknown request type: {0}.", message.RequestType)); + + break; } }