我正在使用JSch来访问sftp文件。上传后,我更改了文件的权限。但如何改变业主?我找不到有好的例子。我想如何使用JSch sftp chown?
chown Administrator:Administrators filename.exe
就像你在Linux会做,但JSch chown命令取整数,而不是业主的字符串:组。那是什么样的废话?
下面是我的一些代码
jSch = new JSch();
if (useKey) jSch.addIdentity(privateKey);
session = jSch.getSession(user, host, port);
if (!useKey) {
session.setPassword(pass);
session.setConfig("PreferredAuthentications", "password");
}
session.setConfig("StrictHostKeyChecking", "no");
session.connect(FTP_TIMEOUT);
channel = session.openChannel("sftp");
sftp = (ChannelSftp) channel;
sftp.connect(FTP_TIMEOUT);
sftp.put(fis,file.getName());
String permissions = "744";
int octal = Integer.parseInt(permissions,8); //jsh uses octal, not decimal
if (file.getName().endsWith(".exe")) { //make exe files executable
sftp.chmod(octal,file.getName());
sftp.chown(this-is-an-integer-not-a-string, file.getName());
}
店主是管理员,这是正确的。但是该组是None并且应该是Administrators。只有UID输入时如何更改组? – user3217883