Remote command takes minutes - SSH

This is a discussion on Remote command takes minutes - SSH ; Hi all, I'm trying to run a remote command using SSH, but it's taking several minutes to complete. Example shell output (anonymized): $ time ssh -p 12345 -v example.org "ls" .... [takes less than a second] jdoe@example.org 's password: archivedebug1: ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Remote command takes minutes

  1. Remote command takes minutes

    Hi all,

    I'm trying to run a remote command using SSH, but it's taking several
    minutes to complete.

    Example shell output (anonymized):
    $ time ssh -p 12345 -v example.org "ls"
    .... [takes less than a second]
    jdoe@example.org's password:
    archivedebug1: Authentication succeeded (password).
    debug1: channel 0: new [client-session]
    debug1: Entering interactive session.
    debug1: Sending environment.
    debug1: Sending env LANG = en_US.UTF-8
    debug1: Sending command: ls
    [here it hangs for a loooong time]
    debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
    [result of "ls" command]
    [hangs here as well]
    debug1: channel 0: free: client-session, nchannels 1
    debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 452.9
    seconds
    debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
    debug1: Exit status 0

    real 7m39.620s
    user 0m0.012s
    sys 0m0.004s

    Those are actual times! I've tried logging in using
    ssh -p 12345 example.org
    and then running the command, and that takes seconds and milliseconds,
    respectively, as expected.

    Why is the remote command execution so slow?

    --
    Victor Engmark

  2. Re: Remote command takes minutes

    On 20 Mar, 08:51, l0b0 wrote:
    > Hi all,
    >
    > I'm trying to run a remote command using SSH, but it's taking several
    > minutes to complete.
    >
    > Example shell output (anonymized):
    > $ time ssh -p 12345 -v example.org "ls"
    > ... [takes less than a second]
    > j...@example.org's password:
    > archivedebug1: Authentication succeeded (password).
    > debug1: channel 0: new [client-session]
    > debug1: Entering interactive session.
    > debug1: Sending environment.
    > debug1: Sending env LANG = en_US.UTF-8
    > debug1: Sending command: ls
    > [here it hangs for a loooong time]
    > debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
    > [result of "ls" command]
    > [hangs here as well]
    > debug1: channel 0: free: client-session, nchannels 1
    > debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 452.9
    > seconds
    > debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
    > debug1: Exit status 0
    >
    > real * *7m39.620s
    > user * *0m0.012s
    > sys * * 0m0.004s
    >
    > Those are actual times! I've tried logging in using
    > ssh -p 12345 example.org
    > and then running the command, and that takes seconds and milliseconds,
    > respectively, as expected.
    >
    > Why is the remote command execution so slow?


    So you've got it running on port 12345. Fine. Are there any other
    differences? And do you have any sets of clever oddnesses in
    your .profile htat behave differently depending on whether you have a
    tty? And does it make a difference if your ssh login happens *first*,
    and hten you try the ssh remote command? I'm thinking about reverse
    DNS for the SSH server, and randomness generation on both machines.

    Also, what happens if you use "ssh -p 12345 example.org ls" on
    example.org itself?

  3. Re: Remote command takes minutes

    On Mar 20, 10:11 am, Nico Kadel-Garcia wrote:
    > On 20 Mar, 08:51, l0b0 wrote:
    >
    > > I'm trying to run a remote command using SSH, but it's taking several
    > > minutes to complete.

    >
    > > Example shell output (anonymized):
    > > $ time ssh -p 12345 -v example.org "ls"
    > > ... [takes less than a second]
    > > j...@example.org's password:
    > > archivedebug1: Authentication succeeded (password).
    > > debug1: channel 0: new [client-session]
    > > debug1: Entering interactive session.
    > > debug1: Sending environment.
    > > debug1: Sending env LANG = en_US.UTF-8
    > > debug1: Sending command: ls
    > > [here it hangs for a loooong time]
    > > debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
    > > [result of "ls" command]
    > > [hangs here as well]
    > > debug1: channel 0: free: client-session, nchannels 1
    > > debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 452.9
    > > seconds
    > > debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
    > > debug1: Exit status 0

    >
    > > real 7m39.620s
    > > user 0m0.012s
    > > sys 0m0.004s

    >
    > > Those are actual times! I've tried logging in using
    > > ssh -p 12345 example.org
    > > and then running the command, and that takes seconds and milliseconds,
    > > respectively, as expected.

    >
    > > Why is the remote command execution so slow?

    >
    > So you've got it running on port 12345. Fine. Are there any other
    > differences?


    /etc/ssh/sshd_config specifies "Protocol 2", but I think that's
    default. Other than that and the port, I'm using the default
    sshd_config.

    > And do you have any sets of clever oddnesses in
    > your .profile htat behave differently depending on whether you have a
    > tty?


    Only this, which is default in Ubuntu:
    if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f ~/.bashrc ]; then
    . ~/.bashrc
    fi
    fi

    > And does it make a difference if your ssh login happens *first*,
    > and hten you try the ssh remote command? I'm thinking about reverse
    > DNS for the SSH server, and randomness generation on both machines.
    >
    > Also, what happens if you use "ssh -p 12345 example.org ls" on
    > example.org itself?


    After running
    $ ssh -p 12345 example.org
    both of these are fast:
    $ time ls
    ....
    real 0m0.007s
    user 0m0.004s
    sys 0m0.000s

    $ time ssh -p 2222 localhost "ls"
    ....
    real 0m2.966s
    user 0m0.012s
    sys 0m0.004s

    --
    Victor Engmark

  4. Re: Remote command takes minutes

    l0b0 wrote:
    > On Mar 20, 10:11 am, Nico Kadel-Garcia wrote:
    > > On 20 Mar, 08:51, l0b0 wrote:
    > >
    > > > I'm trying to run a remote command using SSH, but it's taking several
    > > > minutes to complete.

    > >
    > > > Example shell output (anonymized):
    > > > $ time ssh -p 12345 -v example.org "ls"
    > > > ... [takes less than a second]
    > > > j...@example.org's password:
    > > > archivedebug1: Authentication succeeded (password).
    > > > debug1: channel 0: new [client-session]
    > > > debug1: Entering interactive session.
    > > > debug1: Sending environment.
    > > > debug1: Sending env LANG = en_US.UTF-8
    > > > debug1: Sending command: ls
    > > > [here it hangs for a loooong time]
    > > > debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
    > > > [result of "ls" command]
    > > > [hangs here as well]
    > > > debug1: channel 0: free: client-session, nchannels 1
    > > > debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 452.9
    > > > seconds
    > > > debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
    > > > debug1: Exit status 0

    > >
    > > > real 7m39.620s
    > > > user 0m0.012s
    > > > sys 0m0.004s

    > >
    > > > Those are actual times! I've tried logging in using
    > > > ssh -p 12345 example.org
    > > > and then running the command, and that takes seconds and milliseconds,
    > > > respectively, as expected.

    > >
    > > > Why is the remote command execution so slow?

    > >
    > > So you've got it running on port 12345. Fine. Are there any other
    > > differences?

    >
    > /etc/ssh/sshd_config specifies "Protocol 2", but I think that's
    > default. Other than that and the port, I'm using the default
    > sshd_config.
    >
    > > And do you have any sets of clever oddnesses in
    > > your .profile htat behave differently depending on whether you have a
    > > tty?

    >
    > Only this, which is default in Ubuntu:
    > if [ -n "$BASH_VERSION" ]; then
    > # include .bashrc if it exists
    > if [ -f ~/.bashrc ]; then
    > . ~/.bashrc
    > fi
    > fi
    >
    > > And does it make a difference if your ssh login happens *first*,
    > > and hten you try the ssh remote command? I'm thinking about reverse
    > > DNS for the SSH server, and randomness generation on both machines.
    > >
    > > Also, what happens if you use "ssh -p 12345 example.org ls" on
    > > example.org itself?

    >
    > After running
    > $ ssh -p 12345 example.org
    > both of these are fast:
    > $ time ls
    > ...
    > real 0m0.007s
    > user 0m0.004s
    > sys 0m0.000s
    >
    > $ time ssh -p 2222 localhost "ls"
    > ...
    > real 0m2.966s
    > user 0m0.012s
    > sys 0m0.004s


    Now this is getting ridiculous - SSH-ing in and then running commands
    works fine now, and is quick as anything. But now every remote command
    times out.

    $ tail -2 /var/log/auth.log
    Apr 25 13:18:18 hostname sshd[27985]: Accepted publickey for username
    from 128.xxx.yyy.zzz port 42487 ssh2
    Apr 25 13:18:18 hostname sshd[27987]: pam_unix(ssh:session): session
    opened for user username by (uid=0)

    $ ssh -v
    OpenSSH_4.6p1 Debian-5ubuntu0.2, OpenSSL 0.9.8e 23 Feb 2007

    Any tips on how to debug this? Both machines are behind a firewall.

    --
    Victor Engmark

+ Reply to Thread