scpは動作しませんが、sshは動作します

scpは動作しませんが、sshは動作します

私のローカルコンピュータとリモートコンピュータの両方が同じネットワークに接続されています。これは私のAndroid携帯電話のホットスポットです。 SSH経由でリモートコンピュータに接続できますが、問題は、一部のファイルをリモートコンピュータにコピーしようとするとエラーメッセージが表示されることです。奇妙なことに、scp昨日はうまくいきましたが、今日は次のエラーメッセージが表示されます。scp -v file.txt [email protected]:/root

Executing: program /data/data/com.termux/files/usr/bin/ssh host 191.168.43.85, user root, command scp -v -t /root
OpenSSH_7.7p1, OpenSSL 1.0.2o  27 Mar 2018
debug1: Reading configuration data /data/data/com.termux/files/usr/etc/ssh/ssh_config
debug1: Connecting to 191.168.43.85 [191.168.43.85] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /data/data/com.termux/files/home/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /data/data/com.termux/files/home/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /data/data/com.termux/files/home/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /data/data/com.termux/files/home/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /data/data/com.termux/files/home/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /data/data/com.termux/files/home/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /data/data/com.termux/files/home/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /data/data/com.termux/files/home/.ssh/id_ed25519-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /data/data/com.termux/files/home/.ssh/id_xmss type -1
debug1: key_load_public: No such file or directory
debug1: identity file /data/data/com.termux/files/home/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.7
ssh_exchange_identification: read: Connection reset by peer
lost connection

~/.sshローカルコンピュータで縮小されたコンテンツ。

# ls -la .ssh
total 12
drwx------  2 u0_a334 u0_a334 4096 Jul 25 12:33 .
drwx------ 36 u0_a334 u0_a334 4096 Jul 25 12:05 ..
-rw-------  1 u0_a334 u0_a334    0 Jul 25 12:33 authorized_keys
-rw-r--r--  1 u0_a334 u0_a334  175 Jul 25 11:51 known_hosts

コメント全部確認してみると/etc/hosts.deny犯人ではありませんね。

ローカルコンピュータにあるKnown_hostsファイルの内容。

# cat .ssh/known_hosts
192.168.43.85 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBB4scw5vCUl2dssTS97+5QhiMBIk+/Tc15LoqAoS05i99jMOwRwyRpoNcKTk52d5hprkI7ECIGC9Qrh1KcIniFM=

これは重複ではないと思います。SSHを介してサーバーに接続しようとするとkey_load_publicが発生します:対応するファイルまたはディレクトリなしエラーが発生する

それでも合格できるので、状況が少し違うので、すべてのソリューションを試しました。ssh [email protected]SSHを介してサーバーに接続しようとするとkey_load_publicが発生します:対応するファイルまたはディレクトリなしエラーが発生する

編集する

秘密鍵を生成した後、すべてがうまく機能しますが、秘密鍵なしでscpが機能する理由はまだ混乱しています。

ベストアンサー1

問題は、存在しないSSH秘密鍵を使用しようとすることです。ディレクトリ内に必要なキーはscpありません。id_rsaid_dsaid_ecdsa

/data/data/com.termux/files/home/.ssh/

注文後

ls -la /data/data/com.termux/files/home/.ssh/

返品

total 12
drwx------  2 u0_a334 u0_a334 4096 Jul 25 12:33 .
drwx------ 36 u0_a334 u0_a334 4096 Jul 25 12:05 ..
-rw-------  1 u0_a334 u0_a334    0 Jul 25 12:33 authorized_keys
-rw-r--r--  1 u0_a334 u0_a334  175 Jul 25 11:51 known_hosts

このエラーを修正する方法は2つあります。

最初の可能性は、必要な秘密鍵(おそらくid_rsaそれらの1つまたは一部)をディレクトリにコピーすることです。id_dsaid_ecdsa/data/data/com.termux/files/home/.ssh/

2番目の可能性は、(identity_file)オプションを使用してscp明示的な秘密鍵の使用を明示的に指示することです。-i

scp -i /path/to/id_rsa file.txt [email protected]:/root

IDファイルがどこに保存されているかわかりませんが、機能しているssh場合(OPで説明されているように)オプションを使用して実行し、ssh接続verboseログで次のコマンドで使用されるIDファイルパスを見つけますssh

ssh -vvv [email protected]

おすすめ記事