首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >php执行scp主机密钥验证失败

php执行scp主机密钥验证失败
EN

Stack Overflow用户
提问于 2013-02-19 17:38:06
回答 1查看 5.5K关注 0票数 5

我试着用scp复制文件。我使用PHP的shell_exec命令来执行以下命令:

代码语言:javascript
复制
scp -i/home/raul/nueva_clave -q -v /home/raul/www/CA/app/tmp/ImagenWeb TA-adm@127.0.0.1:/home/TA-adm/images/IMG_3846.JPG 2>&1

服务器地址为127.0.0.1,因为我仍在开发脚本。我以后再换。

我使用scp而不是PHP的ssh2_scp_send,因为我不想在proyect中写入服务器的密码。相反,我想使用公钥。但是当我在PHP中执行时,结果是:

代码语言:javascript
复制
Executing: program /usr/bin/ssh host 127.0.0.1, user TA-adm, command scp -v -t -- /home/TA-adm/images/IMG_3846.JPG
OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 22.
debug1: Connection established.
debug1: SELinux support disabled
Could not create directory '/nonexistent/.ssh'.
debug1: identity file /home/raul/nueva_clave type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/raul/nueva_clave-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 2d:71:67:30:89:c0:1a:64:41:b5:07:8f:6d:c5:9f:13
debug1: read_passphrase: can't open /dev/tty: No such device or address
Host key verification failed.
lost connection

如果我在终端中与我的用户一起执行这个命令,我就没有问题。我认为问题在于用户没有执行scp。我在用Ubuntu。

EN

回答 1

Stack Overflow用户

发布于 2015-01-27 09:55:07

(由OP在问题编辑中回答。搬到这里了。见Question with no answers, but issue solved in the comments (or extended in chat) )

“任择议定书”写道:

问题解决了。我使用了以下选项:

代码语言:javascript
复制
-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no

因此,scp命令不会尝试在用户无人的文件known_host文件中插入主机(scp无法创建该文件,因为用户没有家,也没有~/.ssh)。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14963892

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档