我有一个用户帐户,但尝试使用此帐户却导致rssh异常。是否有可能使用以外的其他方式授予目录权限ChannelExec
。基于例外情况,我知道该帐户无法用于ChannelExec
授予目录或文件的权限。因此,在没有访问该用户帐户访问权限的情况下,该帐户还有其他方法可以授予文件权限rssh
。请给您想法。
代码 :
channelSftp = (ChannelSftp) channel;
ChannelExec channelexe = (ChannelExec) session.openChannel("exec");
channelexe.setCommand("chmod 777 -R " + depDir);
channelexe.connect();
System.out.println("channelexe.getExitStatus:"+channelexe.getExitStatus());
输出 :
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.
无需使用“ exec”通道。
public void chmod(int permissions, String path)
请注意,该方法将权限作为整数。因此,您不能使用777
,因为这是权限的八进制表示形式。
等效的十进制表示形式是511
(= 7 * 8 ^ 2 + 7 * 8 ^ 1 + 7 * 8 ^ 0)。
另请参见十进制到八进制转换。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句