5

I am trying to transfer a file from my local machine to a remote machine.

When I use scp without -v option it gives only following output:

.--. or '\033[0;1;33;93m.-\033[0;1;32;92m-.\033[0m'

When I try scp with -v option I get following output, seems files transferred succesfully:

--

$ scp -v file.sh  user@IP:/home/user/foo

debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LC_PAPER = tr_TR.UTF-8
debug1: Sending env LC_ADDRESS = tr_TR.UTF-8
debug1: Sending env LC_MONETARY = tr_TR.UTF-8
debug1: Sending env LC_NUMERIC = tr_TR.UTF-8
debug1: Sending env LC_ALL = en_US.UTF-8
debug1: Sending env LC_TELEPHONE = tr_TR.UTF-8
debug1: Sending env LC_IDENTIFICATION = tr_TR.UTF-8
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending env LC_MEASUREMENT = tr_TR.UTF-8
debug1: Sending env LC_CTYPE = UTF-8
debug1: Sending env LC_TIME = tr_TR.UTF-8
debug1: Sending env LC_NAME = tr_TR.UTF-8
debug1: Sending command: scp -v -t /home/user/foo
    .--.
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 2504, received 2668 bytes, in 1.7 seconds
Bytes per second: sent 1510.2, received 1609.1
debug1: Exit status 0

Please see sshd_config file here. Please note that I can ssh into the remote machine. Also ssh user@IP pwd returns /home/user.

[Q] scp successfully transfers file but it does not show up on the remote machine. What might be the reason for this and how could I solve it?

12
  • How do you know the file doesn't show up on the remote machine? Commented May 1, 2018 at 9:50
  • I do ls on the folder path at remote machine, it returns nothing. @Andrew Henle
    – alper
    Commented May 1, 2018 at 9:51
  • 1
    From the remote machine, what does ls -l /home/user/foo show? Commented May 1, 2018 at 13:48
  • 1
    Possible duplicate of unix.stackexchange.com/questions/18231/scp-fails-without-error Commented May 11, 2018 at 17:28
  • 1
    Thanks adding # If not running interactively, don't do anything [[ $- == *i* ]] || return on top of my .bashrc file solved the problem! @ Anthony Geoghegan
    – alper
    Commented May 11, 2018 at 17:33

3 Answers 3

10
+50

Make sure you don't have startup scripts in your shell that echo data to the terminal. This might be in .bashrc or .profile

When scp connects to the remote host, it expects to see the SSH server headers followed by an opened stdin stream.

If your .profile on the remote host echoes any output, it causes scp to fail silently. If this is the case, you might want to remove this or put a guard condition to ensure that nothing gets printed in the absence of a controlling tty device. See tty command for that.

5
  • I have a startup script on my .bashrc which I to keep it. I am not sure it may be the reason to cause this problem. @rohit.
    – alper
    Commented May 6, 2018 at 11:34
  • 1
    this is most probably a reason, please make sure that you have something like # If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac in beginning of your bashrc and you not run external commands in .profile
    – zb'
    Commented May 6, 2018 at 13:34
  • That's an interesting snippet @zb'. I've always used [[ "$(tty)" != "not a tty" ]] && return
    – rohit
    Commented May 7, 2018 at 5:12
  • @rohit it is from my default bashrc, ubuntu
    – zb'
    Commented May 7, 2018 at 5:35
  • 1
    @Alper this is the most likely cause of the problem. There's something in one of your shell startup scripts that prints .--. along with ANSI escape sequences. You can keep your startup script but edit it to include the check for an interactive shell. See unix.stackexchange.com/a/257613/22812 Commented May 11, 2018 at 17:24
0

I normally use hostname (DNS name, rather than IP). Please try the below:

scp -rv file.sh dest@host@DNS:/home/user/foo/
1
  • I am actually using DNS name, it didn't make any change. @user227863
    – alper
    Commented May 1, 2018 at 11:24
0

What OS and file system are you running on your remote machine? What are the file attributes before you copy it? Is it readable by everyone?

As a further troubleshooting step, try to copy the file back from your remote machine to your local machine, but name it something else.

scp user@IP:/remote/machine/remoteFile /local/machine/remoteFileRenamed
1
  • Ubuntu ext4. Please note that copy operation between host and remote machine does not work. Basically on my host I tried ... and that file didn’t show up on my host machine. @user43633
    – alper
    Commented May 6, 2018 at 11:50

You must log in to answer this question.

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