5

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 です。後で変更します。

プロジェクトにサーバーのパスワードを書きたくないので、PHP の ssh2_scp_send の代わりに scp を使用しています。代わりに、公開鍵を使用したいと思います。しかし、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を使用しています。

4

1 に答える 1

3

(質問の編集でOPが回答しました。ここに移動しました。回答のない質問を参照してください。ただし、コメントで問題が解決しました(またはチャットで拡張されました)

OP は次のように書いています。

解決しました。オプションを使用しました:

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

そのため、scpコマンドはユーザー nobody のファイル file にホストを挿入しようとはしませんknown_host(scpユーザー nobody にはホームがないため、ファイルを作成できません~/.ssh)。

于 2015-01-27T09:55:07.867 に答える