Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public SSHConnectAct()
- {
- string host = "111.11.11.111";
- string username = "user";
- string password = "password";
- var proxy_host = "222.22.22.2";
- int port = 22;
- int proxy_port = 80;
- PasswordConnectionInfo connectionInfo = new PasswordConnectionInfo(host, port, username, password, ProxyTypes.Http, proxy_host, proxy_port);
- connectionInfo.Timeout = TimeSpan.FromSeconds(30);
- SshClient client = new SshClient(connectionInfo);
- try
- {
- client.Connect();
- if (client.IsConnected)
- {
- client.RunCommand("python3 /path/script.py");
- MessageBox.Show("Скрипт запущен");
- client.Disconnect();
- MessageBox.Show("SSH соединение закрыто");
- }else{
- MessageBox.Show("Соединение не активно");
- }
- }
- catch (Exception e)
- {
- MessageBox.Show("Ошибка подключения "+e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement