omer oruc
omer oruc

Reputation: 11

How to run command from a SFTP server programmatically using SharpSSH?

i use Tamir SharpSSH everything is working but i need to run command with c# code i put file server but i need to run command for works anybody know this ?

SshTransferProtocolBase sshCp;
const string sftp_host = "xxx";
const string sftp_user = "xxx";
const string sftp_pass = "xxx";
const int sftp_port = 22;
var sftp = new Sftp(sftp_host, sftp_user, sftp_pass);
sftp.Connect(sftp_port);
sftp.Put(@"D:\\" + Teslim + ".txt", "../");
sftp.Close();

this code working i need to run command into root????

Upvotes: 0

Views: 1824

Answers (2)

shf301
shf301

Reputation: 31404

You can't execute a command with Sftp - you have to use an SSH console session to run commands. Tamir SharpSSH supports this with the SshExec object.

See the SshExeText.cs sample for an example of using it.

Upvotes: 0

bluevector
bluevector

Reputation: 3493

You can't execute code on a remote server via (S)FTP.

Upvotes: 0

Related Questions