gpt4 book ai didi

php - php执行时scp主机 key 验证失败

转载 作者:IT王子 更新时间:2023-10-29 00:41:24 25 4
gpt4 key购买 nike

我正在尝试使用 scp 来复制文件。我使用 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

服务器地址是 127.0.0.1 因为我还在开发脚本。我稍后再更改。

我正在使用 scp 而不是 PHP 的 ssh2_scp_send,因为我不想在我的项目中写入服务器的密码。相反,我想使用公钥。但是当我在 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

如果我在终端中用我的用户执行这个命令,我没有问题。我想问题是用户 nobody 正在执行 scp。我正在使用 Ubuntu。

最佳答案

(由 OP 在问题编辑中回答。移至此处。参见 Question with no answers, but issue solved in the comments (or extended in chat))

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).

关于php - php执行时scp主机 key 验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14963892/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com