diff --git a/Myrtille.SSH/Program.cs b/Myrtille.SSH/Program.cs index 364e277..08811ca 100644 --- a/Myrtille.SSH/Program.cs +++ b/Myrtille.SSH/Program.cs @@ -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);