0

我在 perl cgi 文件中使用“Net::SFTP”将文件从我的开发盒中放入 Windows M/C。

手动添加以下新目录(具有 0777 权限)后一切正常:

bash-4.1$ pwd
/.ssh
-bash-4.1$ cd ..
-bash-4.1$ ls -ltra | grep .ssh
drwxrwxrwx 2 root root 4096 Jan 23 23:57 .ssh

问题(如果我不手动添加上面的目录)根据我的理解:Apache is running cgi with user as "nobody" which does not have permission to make directory after connection is established via sftp and I'm getting below error日志中的消息:

xxx.xxx.net: Reading configuration data /.ssh/config
xxx.xxx.net: Reading configuration data /etc/ssh_config
xxx.xxx.net: Connecting to xxx.xxx.xxx.com, port 22.
xxx.xxx.net: Remote protocol version 2.0, remote software version 5.17 FlowSsh: Bitvise SSH Server (WinSSHD) 5.58: free only for personal non-commercial use^M
Math::BigInt: couldn't load specified math lib(s), fallback to Math::BigInt::Calc at /usr/lib/perl5/site_perl/5.8.8/Crypt/DH.pm line 6
xxx.xxx.net: Net::SSH::Perl Version 1.34, protocol version 2.0.
xxx.xxx.net: No compat match: 5.17 FlowSsh: Bitvise SSH Server (WinSSHD) 5.58: free only for personal non-commercial use^M.
xxx.xxx.net: Connection established.
xxx.xxx.net: Sent key-exchange init (KEXINIT), wait response.
xxx.xxx.net: Algorithms, c->s: 3des-cbc hmac-sha1 none
xxx.xxx.net: Algorithms, s->c: 3des-cbc hmac-sha1 none
xxx.xxx.net: Entering Diffie-Hellman Group 1 key exchange.
xxx.xxx.net: Sent DH public key, waiting for reply.
xxx.xxx.net: Received host key, type 'ssh-dss'.
xxx.xxx.net: Permanently added 'xxx.xxx.xxx.com' to the list of known hosts.
**mkdir //.ssh: Permission denied at /usr/lib/perl5/site_perl/5.8.8/Net/SSH/Perl/Util/Hosts.pm line 92**

我试图用互联网上给出的不同方法来解决这个问题,但没有什么对我有用。

有人可以提出可能的解决方案吗?

任何帮助将不胜感激。

4

1 回答 1

0

我最近自己也遇到了同样的问题,你说得对,这是一个权限问题。当您的nobody 进程尝试连接到远程服务器时,它希望将远程主机密钥写入文件。这是您的错误消息中失败的步骤(Hosts.pm 第 92 行)。

我的解决方案是为 NET::SFTP 创建一个无人可写的位置以写入 known_hosts 文件,并在构建 NET::SFTP 连接之前指定该位置。

$ENV{HOME} =  '/nobody/writable/location/';

您可以在http://www.perlmonks.org/?node_id=599078找到有关此问题的更多信息

于 2013-05-23T14:45:52.820 回答