4

My local machine and remote machine are both connected to the same network i.e my Android Phone hotspot. I can connect to remote machine by ssh but, the problem is when I am trying to copy some files into remote machine, I am facing error messages, the strange thing is that yesterday scp was working, but today scp -v file.txt [email protected]:/root giving following error message:

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

Here is content of ~/.ssh folded from local machine

# 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

I checked /etc/hosts.deny all things are commented so it is not culprit.

Here is content of known_hosts file from local machine

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

I think it is not duplicate of this Trying to SSH into server and getting key_load_public: No such file or directory error

Because my situation is a little bit different, as I can still control my remote machine, by means of ssh [email protected] . By the way I tried all solutions from Trying to SSH into server and getting key_load_public: No such file or directory error

Edit

After generating private keys everything is working fine but still I am confused why scp was working without private keys.

8

1 Answer 1

2

The problem is scp tries to use ssh private keys which aren't in place - there are no nesessary keys id_rsa, id_dsa, id_ecdsa inside directory

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

since the command

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

returns

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

There are two possibilities to fix the error.

First possibility is to copy requried private keys (possibly one of them or some of them) id_rsa, id_dsa, id_ecdsa to directory /data/data/com.termux/files/home/.ssh/ .

Second possibility is to instruct explicitly scp to use some definite private key with -i (identity_file) option, i.e.

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

If you don't know where are you identity files stored, but ssh works (as noted in OP), execute ssh with verbose option and find in connection log path to identity file used by ssh:

ssh -vvv [email protected]
6
  • Wouldn't scp use password authentication, just like ssh would, if there are no private keys available?
    – Kusalananda
    Jul 25, 2018 at 10:45
  • @Kusalananda I hope ssh password authentification has been disabled according to best practice recommendation. Let's wait and see reply from OP author.
    – Bob
    Jul 25, 2018 at 10:49
  • @Bob ssh is also trying to search private keys in same directory like scp but then ssh is using password method so after generating private keys now scp is working again
    – Aux
    Jul 25, 2018 at 11:36
  • @Aux Is your scp working already now after private keys were generated? Has the problem gone away?
    – Bob
    Jul 25, 2018 at 11:40
  • @Bob problem gone away :) but still I am confused why scp was working without private keys but now not
    – Aux
    Jul 25, 2018 at 11:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .