0 votes
by (150 points)

Hi,
i am testing Scp module, i want to upload files and set permissions to be executable at same time. What options do i have? I understand i could open 2 connections (ssh&scp) but this does not look very efficient.
taskin

1 Answer

0 votes
by (63.4k points)
selected by
 
Best answer

Hello,

unfortunately, we doesn't support setting permissions in SCP (permissions are set to 644 by default).

The SCP is quite legacy file transfer protocol and we added SCP support for situations where SFTP cannot be used.

Is it possible for you to use SFTP which is quite newer protocol?

Using SFTP you can set permissions like this:

// initialize SFTP client object
var client = new Sftp();
client.Connect(...);
client.Login(...);

// prepare new file attributes
var attributes = new SftpAttributes();
attributes.Permissions = (SftpPermissions)Convert.ToInt32("755", 8);

// set attributes of a file
client.SetAttributes("/data/file.txt", attributes);
...