Ejemplo n.º 1
0
        public Dictionary <String, byte[]> GetSecurityFilePack()
        {
            String[] SecurityFileNames = new String[] {
                "/usr/local/platform/conf/platformConfig.xml",
                "/usr/local/platform/.security/CCMEncryption/keys/dkey.txt"
            };
            Dictionary <String, byte[]> oSecurityFilePack = new Dictionary <String, byte[]>();

            scpClient.Connect();
            if (scpClient.IsConnected)
            {
                foreach (String sFileName in SecurityFileNames)
                {
                    MemoryStream xmlStream = new MemoryStream();

                    scpClient.Download(sFileName, xmlStream);

                    byte[] xmlDataBytes = new byte[xmlStream.Length];
                    xmlStream.Seek(0, SeekOrigin.Begin);
                    xmlStream.Read(xmlDataBytes, 0, (int)xmlStream.Length);
                    oSecurityFilePack[sFileName] = xmlDataBytes;
                    //Console.Write("{0}\n", Functions.encoding.GetString(xmlDataBytes));
                }
                scpClient.Disconnect();
            }
            else
            {
                // Error - not connected
            }
            return(oSecurityFilePack);
        }
Ejemplo n.º 2
0
        private void connToServerAndDownloadBtn_Click(object sender, EventArgs e)
        {
            var ip     = ipTextBox.Text;
            var port   = Int32.Parse(portTextBox.Text);
            var login  = loginTextBox.Text;
            var passwd = passwdTextBox.Text;

            try
            {
                using (var client = new Renci.SshNet.ScpClient(ip, port, login, passwd))
                {
                    client.Connect();
                    client.Download("/var/lib/jboss/acm/topology.structure",
                                    new FileInfo(
                                        Path.Combine(Path.GetDirectoryName(
                                                         Assembly.GetExecutingAssembly().Location), @"Data\topology.structure"))
                                    );
                    client.Disconnect();
                }

                MessageBox.Show("Файл успешно загружен и готов к работе!", "Информация",
                                MessageBoxButtons.OK);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\nПроблемы с подключением. Проверьте работопоспособность" +
                                " сервера и правильность введенных данных", "Ошибка", MessageBoxButtons.OK);
            }
        }
Ejemplo n.º 3
0
        public LiveHostClient(string sHostName, string sRemoteSupportUser, string sRemoteSupportPassphrase)
        {
            RemoteSupportPassphrase oReportSupportPassphrase = new RemoteSupportPassphrase();
            String sUserPassword = oReportSupportPassphrase.Decode(sRemoteSupportPassphrase);

            Renci.SshNet.AuthenticationMethod authMethod = new Renci.SshNet.PasswordAuthenticationMethod(sRemoteSupportUser, sUserPassword);
            scpConnInfo = new Renci.SshNet.ConnectionInfo(sHostName, sRemoteSupportUser, new[] { authMethod });
            scpClient   = new Renci.SshNet.ScpClient(scpConnInfo);

            MemoryStream xmlStream = new MemoryStream();

            scpClient.Connect();
            System.Threading.Thread.Sleep(3000);
            try
            {
                scpClient.Download(@"/usr/local/platform/conf/platformConfig.xml", xmlStream);
            } catch (Exception ex) {
                string bob = ex.Message;
            }

            scpClient.Disconnect();

            byte[] xmlDataBytes = new byte[xmlStream.Length];
            xmlStream.Seek(0, SeekOrigin.Begin);
            xmlStream.Read(xmlDataBytes, 0, (int)xmlStream.Length);

            Console.Write("{0}\n", Functions.encoding.GetString(xmlDataBytes));
        }
Ejemplo n.º 4
0
 private Renci.SshNet.ScpClient GetScpClient()
 {
     if (scp == null)
     {
         scp = new Renci.SshNet.ScpClient(host, user, GetKeyFiles());
     }
     if (!scp.IsConnected)
     {
         scp.Connect();
     }
     return(scp);
 }