Problem: I am using C# .net platform to SFTP a file to remote host with a key file/.pem file and no password.
C#.net source code:
ProcessStartInfo p = new ProcessStartInfo
{
FileName = "sh",
Arguments = "upload.sh " + file
};
p.RedirectStandardOutput = true;
p.UseShellExecute = false;
p.CreateNoWindow = true;
Process proc1 = new Process();
proc1.StartInfo = p;
proc1.Start();
string result = proc1.StandardOutput.ReadToEnd();
log.InfoFormat(result);
upload.sh:
sftp -i testsftp-key testsftp@sftp.xxx-xxx.com
put filename
here
- testsftp-key :.pem filename(key file),
- testsftp :username,
- sftp.xxx-xxx.com :host address.
- filename :file to be uploaded
File is not getting uploaded when exe is executed by rrot user/cronjob. Executing using non-root user like pi uploads the file. Permissions are 777 for all.
Error:
permission denied
How to solve this permission issue?