Change file permissions with SFTP or SCP uing JSch

sunleo

I have a user account, but on trying using this am getting exception for rssh. Is there any possibility to give permission of directory using other way other than ChannelExec. Based on the exception I come to know this account can't use ChannelExec to give permission of a directory or file. Thus is there any other way this account could give file permission without getting access to this user account for rssh. Please give you thoughts.

Code :

channelSftp = (ChannelSftp) channel;
ChannelExec channelexe = (ChannelExec) session.openChannel("exec");
channelexe.setCommand("chmod 777 -R " + depDir);                
channelexe.connect();

System.out.println("channelexe.getExitStatus:"+channelexe.getExitStatus());

Output :

channelexe.getExitStatus:-1:
This account is restricted by rssh.
Allowed commands: scp sftp

If you believe this is in error, please contact your system administrator.
Martin Prikryl

There's no need to use the "exec" channel for this.

Use the ChannelSftp.chmod:

public void chmod(int permissions, String path)

Note that the method takes the permissions as an integer. So you cannot use 777, as that's an octal representation of the permissions.

An equivalent decimal representation is 511 (=7*8^2 + 7*8^1 + 7*8^0).

See also Decimal to Octal Conversion.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to reput on JSch SFTP?

From Dev

JSch sftp channel runs synchronous?

From Dev

nginx + WordPress: Proper user/file permissions for SFTP + auto update?

From Dev

Change permissions of file in Ruby

From Dev

sftp/scp files with bash

From Dev

How to do an atomic SFTP file transfer using JSch, so that the file is not accessable until the write process has finished?

From Dev

Zip file corrupted (sort of) after SFTP transfer/put (Jsch)

From Dev

Java JSch change file encoding while copying

From Dev

JSch SFTP file upload/download - why use the methods that return a stream?

From Dev

How to download SFTP file by using regular expression in JSch

From Dev

Using SCP or SFTP with my ssh config file?

From Dev

sftp/scp files with bash

From Dev

Sftp interface to Scp

From Dev

Unable to view or change file permissions

From Dev

Change permissions upon uploading with scp

From Dev

File permissions changed after SFTP

From Dev

change file permissions in Kali Linux

From Dev

Unable to connect to SFTP after changing file permissions of /home folder

From Dev

Change permissions on file

From Dev

How to pipe a remote file to stdout over scp or sftp?

From Dev

Reading remote file using jsch and sftp - Failure 4

From Dev

JSch SFTP file upload/download - why use the methods that return a stream?

From Dev

Update permissions on folder to let user scp file there?

From Dev

Change file permissions with SFTP or SCP uing JSch

From Dev

Using sftp like scp

From Dev

JSch - Explaining SCP stream reading

From Dev

sftp JSch transfer file to remote cygwin

From Dev

Async sftp file transfer with Jsch?

From Dev

Change permissions of file in CMake

Related Related

HotTag

Archive