Advertisement
Guest User

Untitled

a guest
Mar 16th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. public SSHConnectAct()
  2. {
  3. string host = "111.11.11.111";
  4. string username = "user";
  5. string password = "password";
  6. var proxy_host = "222.22.22.2";
  7. int port = 22;
  8. int proxy_port = 80;
  9. PasswordConnectionInfo connectionInfo = new PasswordConnectionInfo(host, port, username, password, ProxyTypes.Http, proxy_host, proxy_port);
  10. connectionInfo.Timeout = TimeSpan.FromSeconds(30);
  11. SshClient client = new SshClient(connectionInfo);
  12.  
  13. try
  14. {
  15. client.Connect();
  16. if (client.IsConnected)
  17. {
  18. client.RunCommand("python3 /path/script.py");
  19. MessageBox.Show("Скрипт запущен");
  20. client.Disconnect();
  21. MessageBox.Show("SSH соединение закрыто");
  22. }else{
  23. MessageBox.Show("Соединение не активно");
  24. }
  25. }
  26. catch (Exception e)
  27. {
  28. MessageBox.Show("Ошибка подключения "+e);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement