我在perl cgi文件中使用"Net::SFTP“将文件从我的dev box放到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正在运行cgi,用户是"nobody“,在通过sftp建立连接后,该用户没有权限创建目录,并且我在日志中收到以下错误消息:
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**我试着用互联网上给出的不同方法来解决这个问题,但对我来说什么都不起作用。
有没有人能提出可行的解决方案?
任何帮助都将不胜感激。
发布于 2013-05-23 22:45:53
我最近也遇到了同样的问题,你说的没错,这是一个权限问题。当无名氏进程尝试连接到远程服务器时,它希望将远程主机密钥写入文件。这是错误消息中失败的步骤(Hosts.pm第92行)。
我的解决方案是为NET::SFTP创建一个无人可写的位置来写入known_hosts文件,并在构建NET::SFTP连接之前指定该位置。
$ENV{HOME} = '/nobody/writable/location/';有关此问题的更多信息,请访问http://www.perlmonks.org/?node_id=599078
https://stackoverflow.com/questions/14560412
复制相似问题