When I type scp file1 user@host.com:file2 into the command prompt, I get the message

Can't open display
Can't open display
Can't open display
Can't open display
Can't open display
file1                          100%  589KB 589.0KB/s  00:00

And then I wait for about 10 seconds, before the scp returns to the command line. This does not happen with ssh, only with scp. I am using Fedora 18.

  • Would you mind to try an absolute path, e.g.: scp file1 user@host.com:/home/user/file2 ? – mnille Dec 17 '19 at 10:27
  • Same thing happens. – Alex Dec 17 '19 at 10:30

Your profile scripts probably have some commands that expect an interactive session with a terminal emulation. And they fail when executed in a non-interactive scp session.

For example, if you are using bash, such commands should be moved from .bashrc script to .bash_profile.

Or use TERM or PS1 environment variable or similar trick to skip those commands for a non-interactive session.

# If running interactively, then:
if [ "$PS1" ]; then

#### Alex's funky commands might go here                          <------
    /usr/bin/ssh-agent &

    # If this is an xterm set the title to user@host:dir
    case $TERM in
        PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
#### Alex's funky commands might also go here if they apply to xterm sessions  <------


This will not evaluate if you use scp to copy a file, but will if you start an interactive session.

(The sample code is by @Criggie)

|improve this answer|||||
  • 1
    You are correct, it's the commands in .bashrc that were causing this to happen. – Alex Dec 17 '19 at 10:43
  • 1
    Would you share what those commands were, or some information about them, @Alex? – daveloyall Dec 17 '19 at 20:50
  • There were xrandr commands intended to detect which screens are present, and to arrange them in an appropriate order. – Alex Dec 18 '19 at 7:40
  • I thought scp used a special sftp subsystem rather than doing a regular SSH login. – Barmar Dec 18 '19 at 19:08
  • @Barmar 1) scp does not use SFTP subsystem. 2) Even sftp would suffer the same problem - SFTP still runs over SSH login. – Martin Prikryl Dec 19 '19 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.