Skip to content

Commit

Permalink
Merge pull request #130 from pk910/master
Browse files Browse the repository at this point in the history
Fix for Myrtille.SSH connections to non-default ssh port
  • Loading branch information
cedrozor authored Oct 16, 2018
2 parents 5a24f87 + a780f4e commit 70284ac
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Myrtille.SSH/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,17 @@ private static void ConnectSSHClient()
if (string.IsNullOrEmpty(Password))
throw new SshAuthenticationException("Missing Password");

var connectionInfo = new ConnectionInfo(ServerAddress, UserName, new PasswordAuthenticationMethod(UserName, Password));
Uri serverUri;
var serverHost = ServerAddress;
var serverPort = 22;
if (Uri.TryCreate("tcp://" + ServerAddress, UriKind.Absolute, out serverUri))
{
serverHost = serverUri.Host;
if(serverUri.Port > 0)
serverPort = serverUri.Port;
}

var connectionInfo = new ConnectionInfo(serverHost, serverPort, UserName, new PasswordAuthenticationMethod(UserName, Password));
connectionInfo.Encoding = Encoding.UTF8;

client = new SshClient(connectionInfo);
Expand Down

0 comments on commit 70284ac

Please sign in to comment.