2013-02-19 129 views
4

我試圖使用scp來複制文件。我使用PHP的命令了shell_exec執行此命令:由php執行的scp主機密鑰驗證失敗

scp -i/home/raul/nueva_clave -q -v /home/raul/www/CA/app/tmp/ImagenWeb [email protected]:/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 

如果我執行我在我沒有問題終端用戶此命令。我想問題是用戶沒有人執行scp。我正在使用Ubuntu。

+1

密鑰文件進行加密,因爲你通過scp運行此,還有爲重點的解密密碼提示沒有終端顯示在 – 2013-02-19 17:44:14

+0

我已經生成並安裝在我的服務器的公鑰,因此SCP不會提示輸入任何密碼。 – Serpes 2013-02-19 18:32:26

+0

然後可能鑰匙串被加密,這就是提示。無論哪種方式,錯誤文本中的'read_passphrase'行基本上都是這樣說的。有一些提示輸入密碼,但不能,因爲沒有控制終端顯示提示。 – 2013-02-19 18:34:11

回答

1

(。由OP在一個問題回答編輯搬到這裏見Question with no answers, but issue solved in the comments (or extended in chat)

的OP寫道:

它解決。我使用的選項:

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

所以scp命令不嘗試插入的用戶nobody的文件known_host文件的主機(scp不能創建,因爲用戶文件沒有人沒有家,也沒有~/.ssh)。