Ejemplo n.º 1
0
        /// <summary>
        /// Copy a file from the remote to the local machine
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        public FileInfo CopyToLocal(string remoteFileName, string localFileName)
        {
            var scp = new ScpClient(_host, _username, Passwords.FetchPassword(_host, _username));

            scp.Connect();
            var lf = new FileInfo(localFileName);

            scp.Download(remoteFileName, lf);
            return(lf);
        }
Ejemplo n.º 2
0
        public SSHConnection(string host, string username)
        {
            this._host     = host;
            this._username = username;

            _ssh = new SshClient(_host, _username, Passwords.FetchPassword(_host, _username));
            _ssh.Connect();
            _stream = _ssh.CreateShellStream("commands", 240, 200, 132, 80, 240 * 200);

            // Next job, wait until we get a command prompt

            _stream.WriteLine("# this is a test");
            DumpTillFind(_stream, "# this is a test");
            _prompt = _stream.ReadLine();
        }