LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-15-2020, 05:42 AM   #1
Shaggy1
Member
 
Registered: Oct 2010
Posts: 58

Rep: Reputation: 2
scp: cannot see file in local directory after seemingly successful copy


Client side environment:
$ cat /etc/centos-release
CentOS Linux release 7.8.2003 (Core)

$ uname -a
Linux localhost.localdomain 3.10.0-1127.el7.x86_64 #1 SMP Tue Mar 31 23:36:51 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

$ ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017

Serverside environment:
$ cat fedrelver.txt
Fedora release 23 (Twenty Three)
Linux larry-aceraspire 4.8.13-100.fc23.x86_64 #1 SMP Fri Dec 9 14:51:40 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
OpenSSH_7.2p2, OpenSSL 1.0.2j-fips 26 Sep 2016


Hi
I am having an issue with scp seeming to successfully copy a file from the server, but the file not appearing in the directroy when I do it.

The command I am executing is :
$ scp -vvv -P 2305 larry@192.168.88.250:/home/larry/wirelesscmds.txt .
or this
$ scp -vvv -P 2305 larry@192.168.88.250:/home/larry/wirelesscmds.txt wirelesscmds.txt

But though everything seems to go through fine I do not see wirelesscmds.txt in the local directory once the command has completed.

I can successfully ssh on to the server, so ssh works fine (using keys)

I can even run the following command to successfully get a copy of it:
$ ssh -T -p 2305 larry@192.168.88.250 'scp -v -f /home/larry/wirelesscmds.txt < /dev/zero' > tst.txt
Sending file modes: C0666 1621 wirelesscmds.txt

The logs output on client and server side do not seem to be indicating any errors.

I do see the following output when I run the command (with no verbose flag):
POST /usr/local/bin:/usr/bin
Not sure if that indicates what the problem is ?

Are there any commands that could be in the ssh config files which may be affecting the outcome - for example something directing the output to somewhere else (I canoot see anything obvious in them) ?

I have read somewhere in my searches that suggested the ssh key in authorized_keys could contain something that restrict scp - is that possible ?

Does anyone have any suggestions on how I might go about troubleshooting this further ?

Below I have printed out the client-side output when using single -v option. Can anyone see what the error might be from that ? (debug1: Exit status 1 suggests maybe something went wrong - but I cannot tell what) :
larry@localhost mywritedir]$ scp -v -P 2305 'larry@192.168.88.250:/home/larry/wirelesscmds.txt' .
Executing: program /usr/bin/ssh host 192.168.88.250, user larry, command scp -v -f /home/larry/wirelesscmds.txt
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to 192.168.88.250 [192.168.88.250] port 2305.
debug1: Connection established.
debug1: identity file /home/larry/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/larry/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/larry/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/larry/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/larry/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/larry/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/larry/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/larry/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2
debug1: match: OpenSSH_7.2 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.88.250:2305 as 'larry'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: curve25519-sha256@libssh.org need=64 dh_need=64
debug1: kex: curve25519-sha256@libssh.org need=64 dh_need=64
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:E2yU8+XJUDIq6jbga0jumXVg3RhZP8oRPK5Gj+j+iSI
debug1: Host '[192.168.88.250]:2305' is known and matches the ECDSA host key.
debug1: Found key in /home/larry/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRINGersistent:1000)

debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRINGersistent:1000)

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/larry/.ssh/id_rsa
debug1: Server accepts key: pkalg rsa-sha2-512 blen 279
debug1: Authentication succeeded (publickey).
Authenticated to 192.168.88.250 ([192.168.88.250]:2305).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Sending environment.
debug1: Sending env LANG = en_GB.UTF-8
debug1: Sending env LANGUAGE =
debug1: Sending command: scp -v -f /home/larry/wirelesscmds.txt
Sink: POST /usr/local/bin:/usr/bin
POST /usr/local/bin:/usr/bin
[larry@localhost mywritedir]$ debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Sending file modes: C0666 1621 wirelesscmds.txt
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 3076, received 2556 bytes, in 1.3 seconds
Bytes per second: sent 2316.2, received 1924.7
debug1: Exit status 1
 
Old 11-15-2020, 05:53 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,363
Blog Entries: 3

Rep: Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667
If you are using key-based, or certificate-based, authentication then you could use the SFTP client in batch mode:

Code:
echo "get /home/larry/wirelesscmds.txt" \
| sftp -b - -i ~/.ssh/some_key \
        -P 2305 larry@192.168.88.250
Or you can use rsync with a key even on an individual file:

Code:
rsync -gloptv -e 'ssh -i ~/.ssh/some_key' \
        larry@192.168.88.250:/home/larry/wirelesscmds.txt .
The scp utility is on the way out and should be phased out where it is being used. It should definitely be avoided for new projects.
 
Old 11-15-2020, 09:17 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,883

Rep: Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250
there is an exit status 1 at the end. I don't really know why, probably permission issue?
 
Old 11-15-2020, 09:33 AM   #4
Shaggy1
Member
 
Registered: Oct 2010
Posts: 58

Original Poster
Rep: Reputation: 2
Thank you very much for the reply.

First I did not know that scp was becoming deprecated, so thank you for the link there. I will start moving to using scp.

My attempt to use sftp failed gave me the following error:
Received message too long 1347375956

which led me to the following link:
https://stackoverflow.com/questions/...ssage-too-long
saying this is usually due to a login script outputtin something an messing up the protocol ...
... and indeed there was an echo statement in the /etc/bashrc on my server.
Commenting this out and both scp and sftp work (but I'll start moving to us sftp).

Problem solved. Thank you for your help.
 
1 members found this post helpful.
Old 11-15-2020, 09:43 AM   #5
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,363
Blog Entries: 3

Rep: Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667
If /etc/ssh/sshrc or the user equivalens produce anything to STDOUT, that will jam both SFTP and SCP, even if it is just a newline or other whitespace. I knew that but had not even considered it here in this case. So, good detective work there. An alternative to commenting out that part of the script is to send the output to STDERR instead.
 
Old 11-15-2020, 05:07 PM   #6
computersavvy
Member
 
Registered: Aug 2016
Posts: 701

Rep: Reputation: 214Reputation: 214Reputation: 214
As long as the sshd daemon is running on the host you are connecting to the equivalent command using rsync would be:
Code:
 rsync -av larry@192.168.88.250:~/wirelesscmds.txt .
It will ask for a password then should do the copy.
 
Old 11-15-2020, 09:44 PM   #7
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 16,947
Blog Entries: 27

Rep: Reputation: 5179Reputation: 5179Reputation: 5179Reputation: 5179Reputation: 5179Reputation: 5179Reputation: 5179Reputation: 5179Reputation: 5179Reputation: 5179Reputation: 5179
Please surround terminal output with "code" tags, which become available when you click the "Go Advanced" button beneath the compose/edit post window. They make terminal output much easier to read.

Have you tried sshing into the target system and using "locate" to find the wayward file?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
scp drops connection after sending the scp -t command MasterPO Linux - Software 12 03-15-2020 05:49 PM
[SOLVED] check for $HOME directory after a successful login ( ssh/scp ) paziulek Linux - Security 1 12-14-2017 04:07 PM
how would you use scp to copy your ~/.bashrc file from bravo to the local system? marty gallagher Linux - Newbie 1 11-10-2011 09:28 PM
Using SCP to copy to local knghtz Linux - Newbie 1 08-19-2009 02:53 PM
scp: copy a file from local machine to remote machine seran Linux - Newbie 8 10-30-2007 01:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration