简体   繁体   English

由php执行时,scp主机密钥验证失败

[英]scp host key verification failed when executed by php

I'm trying to use scp to copy files. 我正在尝试使用scp复制文件。 I use the command shell_exec of PHP to execute this command: 我使用PHP的shell_exec命令执行以下命令:

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

The server address is 127.0.0.1 because I'm still developing the script. 服务器地址为127.0.0.1,因为我仍在开发脚本。 I'll change it later. 稍后再更改。

I'm using scp instead of ssh2_scp_send of PHP because I don't want to write the password of the server in my proyect. 我使用的是scp而不是PHP的ssh2_scp_send,因为我不想在proyect中写入服务器的密码。 Instead og that I'd like to use a public key. 相反,我想使用公共密钥。 But when I execute in PHP this is the result: 但是,当我在PHP中执行时,结果如下:

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

If I execute this command with my user in the terminal I have no problems. 如果我在终端中与用户一起执行此命令,则不会有任何问题。 I suppose that the problem is that the user nobody is executing the scp. 我想问题是用户没有人执行scp。 I'm using Ubuntu. 我正在使用Ubuntu。

(Answered by the OP in a question edit. Moved here. See Question with no answers, but issue solved in the comments (or extended in chat) ) (由OP在问题编辑中回答。移至此处。请参阅无答案的问题,但问题已在注释中解决(或在聊天中扩展)

The OP wrote: OP写道:

It's SOLVED. 解决了。 I've used the options: 我使用了以下选项:

-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no

so the scp command doesn't try to insert the host in the file known_host file of the user nobody ( scp can't create the file because the user nobody has no home neither ~/.ssh ). 因此, scp命令不会尝试将主机插入用户nobody的文件known_host文件中( scp无法创建该文件,因为用户nobody也不存在~/.ssh )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM