Ejemplo n.º 1
0
        /// <summary>
        /// Login
        /// </summary>
        /// <param name="shellFactory"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        private static async Task <ISecureShell> LoginAsync(IShellFactory shellFactory,
                                                            CliOptions options)
        {
            var user = options.GetValueOrDefault <string>("-u", "--user", null);
            var pw   = options.GetValueOrDefault <string>("-p", "--password", null);

            while (string.IsNullOrEmpty(user))
            {
                Console.WriteLine("User:"******"Password:"******"-t", "--timeout", -1))) {
                return(await shellFactory.OpenSecureShellAsync(
                           options.GetValue <string>("-h", "--host"),
                           options.GetValueOrDefault("-p", "--port", 22),
                           creds, cts.Token));
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Open shell to destination
 /// </summary>
 /// <param name="factory"></param>
 /// <param name="host"></param>
 /// <param name="credentials"></param>
 /// <returns></returns>
 public static Task <ISecureShell> OpenSecureShellAsync(this IShellFactory factory,
                                                        string host, NetworkCredential credentials) =>
 factory.OpenSecureShellAsync(host, credentials, CancellationToken.None);
Ejemplo n.º 3
0
 /// <summary>
 /// Open shell to destination
 /// </summary>
 /// <param name="factory"></param>
 /// <param name="host"></param>
 /// <param name="userName"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public static Task <ISecureShell> OpenSecureShellAsync(this IShellFactory factory,
                                                        string host, string userName, string password) =>
 factory.OpenSecureShellAsync(host, new NetworkCredential(userName, password));
Ejemplo n.º 4
0
 /// <summary>
 /// Open shell to destination
 /// </summary>
 /// <param name="factory"></param>
 /// <param name="host"></param>
 /// <param name="port"></param>
 /// <param name="userName"></param>
 /// <param name="password"></param>
 /// <param name="ct"></param>
 /// <returns></returns>
 public static Task <ISecureShell> OpenSecureShellAsync(this IShellFactory factory,
                                                        string host, int port, string userName, string password, CancellationToken ct) =>
 factory.OpenSecureShellAsync(host, port, new NetworkCredential(userName, password), ct);
Ejemplo n.º 5
0
 /// <summary>
 /// Open shell to destination
 /// </summary>
 /// <param name="factory"></param>
 /// <param name="host"></param>
 /// <param name="credentials"></param>
 /// <param name="ct"></param>
 /// <returns></returns>
 public static Task <ISecureShell> OpenSecureShellAsync(this IShellFactory factory,
                                                        string host, NetworkCredential credentials, CancellationToken ct)
 {
     return(factory.OpenSecureShellAsync(host, 22, credentials, ct));
 }