The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   Networking (http://hintsforums.macworld.com/forumdisplay.php?f=14)
-   -   Can't SCP/SFTP to local Linux servers on wireless (http://hintsforums.macworld.com/showthread.php?t=64313)

CAlvarez 12-04-2006 06:57 PM

Can't SCP/SFTP to local Linux servers on wireless
 
This is a truly bizarre problem, but I have spent a lot of time testing it and it's 100% repeatable.

The servers are Debian Linux, on a 192.168.100.x address. These are long-running servers which I have connected to often in the past, but have never been able to connect to with my new MBP. This still works with Transmit on other Macs.

The problem only happens when my computer is inside the network, on the wireless network. It works fine when wired, or over a VPN or with a direct outside IP address from any remote location even when using wireless in those locations.

I have tried using the IP addresses and the names.

The symptom is that SCP, SFTP, or Transmit will stay in "connecting" mode for a very long time (around 15 minutes I think) then fail with a "permission denied" error. However, if I enter invalid login data, it fails immediately with the same error. Only if the login details are correct, does it hang for a long time.

Freaky.

trevor 12-04-2006 08:05 PM

Can you show us /etc/sshd_config (or actually on Linux boxes, it's typically found at /etc/ssh/sshd_config) on the ssh server?

Also, can you copy/paste a transcript of a connection attempt to one while using the -v flag (so for example ssh -v adminuser15@192.168.10.102)?

Trevor

hayne 12-04-2006 08:16 PM

Note also that it is sometimes useful to turn on debugging on the server as well. I recall one case where I couldn't figure out what the incompatibility was until I did that.

You should of course try the usual things like lowering the MTU (more often a problem on wireless networks) and disabling IPv6.

A last resort would be to look at the packets using Ethereal.

CAlvarez 12-05-2006 02:55 AM

Interesting thoughts on IPv6 and MTU. I made no changes to them to start with, but worth a try. I won't be at the site until Wednesday though.

Here's sshd_config:

Code:

# Package generated configuration file
# See the sshd(8) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile        %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

UsePAM yes

I should be clear that SSH works perfectly. It's only SFTP and SCP that fail. I won't be able to get a connection log for those until I'm at the site again though.

CAlvarez 12-07-2006 05:26 PM

So here's what the verbose switch gives me. First it does this then hangs:
Code:

Executing: program /usr/bin/ssh host 192.168.100.28, user (unspecified), command scp -v -t /etc/asterisk
OpenSSH_4.2p1, OpenSSL 0.9.7l 28 Sep 2006
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to asterisk2.wgrusers.com [192.168.100.28] port 22.
debug1: Connection established.
debug1: identity file /Users/Carlos/.ssh/identity type -1
debug1: identity file /Users/Carlos/.ssh/id_rsa type 1
debug1: identity file /Users/Carlos/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3p2 Debian-3
debug1: match: OpenSSH_4.3p2 Debian-3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.2
debug1: Miscellaneous failure
No credentials cache found

debug1: Miscellaneous failure
No credentials cache found

debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'asterisk2.wgrusers.com' is known and matches the RSA host key.
debug1: Found key in /Users/Carlos/.ssh/known_hosts:4
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/Carlos/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending command: scp -v -t /etc/asterisk

It stays there for a long time, probably 15 minutes, then:
Code:

debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Read from remote host asterisk2.wgrusers.com: Operation timed out
debug1: Transferred: stdin 0, stdout 0, stderr 67 bytes in 511.3 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.1
debug1: Exit status -1
lost connection

Seems meaningless to me.

hayne 12-07-2006 05:48 PM

Probably not the issue, but 'man scp' on my 10.4.8 machine says nothing about a "-t" option.

CAlvarez 12-07-2006 06:56 PM

Yeah, I don't know what that is, but it was NOT on my command line. The command line is:

scp -v localfile server:/remotedir

hayne 12-07-2006 08:07 PM

I looked at the source code for 'scp' (Darwin10.4.8.ppc/OpenSSH-57.3/openssh/scp.c) and as far as I can understand, what is happening is that it has gone into a client-server mode where it issues commands to the server (the remote sshd) and the "-t" we see in the debug output is one of the flags that is only used internally (in this mode) - it means "to" and this flag is triggered by the detection of a colon in the 2nd arg to 'scp'
(your 2nd arg was "server:/remotedir") but there is no colon in the first argument ("localfile").
I.e. it uses the "-t" when the transfer is from a local file to a remote directory.

The debug log shows:
Quote:

debug1: Sending command: scp -v -t /etc/asterisk
This indicates that the remote directory (the target of the transfer) is "/etc/asterisk".
It is sending this command to the remote server.
It seems from the source code that it is expecting a response from the server before it will start to transmit the bytes of the source file.
The relevant source code looks like this:
Code:

if (remin == -1) {
        len = strlen(targ) + CMDNEEDS + 20;
        bp = xmalloc(len);
        (void) snprintf(bp, len, "%s -t %s", cmd, targ);
        host = cleanhostname(thost);
        if (do_cmd(host, tuser, bp, &remin,
            &remout, argc) < 0)
                exit(1);
        if (response() < 0)
                exit(1);
        (void) xfree(bp);
}
source(1, argv + i);

The 'do_cmd' in the above is what is sending the above "scp -v -t /etc/asterisk" command.
The later call to 'response()' is what is waiting for a response from the server.
It is the final line that invokes 'source(1, argv + i)' that is responsible for sending the bytes of the source file to the server. ('argv' is pointing to your "localfile")

If I'm understanding it correctly, the 'source' function should start off by printing a debug message "Sending file modes:"
It should also show a "progress meter" of some sort if that option has been used.
So it looks like in your case it isn't getting into the 'source' function because it is waiting for a response to the initial 'scp' command from the server.

CAlvarez 12-08-2006 12:02 AM

Very interesting overview, thanks. I know nothing about programming, but you really helped me understand what it's doing and actually understand the code.

What's truly bizarre is that this is obviously a networking issue with this specific computer. Well, I say that because of these facts:

Only happens on this laptop
Only happens on wireless connection inside the network
Doesn't happen when wired
Doesn't happen on wireless outside the network via VPN or directly over the internet

It is also happening with Transmit, which I assume uses its own code and not the underlying Unix programs (I could be wrong).

While networking is my expertise, I can't picture what would happen to ONLY SCP/SFTP traffic between only this computer and Linux servers.

hayne 12-08-2006 12:34 AM

It is indeed difficult to conjure up a scenario that would fit the observations.
Is there anything "interesting" about the name of this laptop by any chance?
Does the problem occur with more than one Linux server?
Can you do scp in the reverse direction (transfer a file from the Linux machine to the laptop)?

It might be interesting to try to capture the packets with Ethereal and see what the difference is in the cases where it works (e.g Ethernet) versus those when it doesn't (Airport). I don't know if Ethereal can (intelligibly) show the packets of an SSH-exchange though - maybe it has a man-in-the-middle mode that can do this?

It would also be interesting (and probably rather easier) to turn on maximum debugging in the Linux server's sshd. I recall doing this once and I think I had to edit the xinit config file or something (to add the appropriate "-d" or whatever it is). That should show you what the server receives (e.g. the above "scp -v -t /etc/asterisk" command) and what it does in response.

By the way, you could find out if Transmit is using the 'scp' utility (or whatever) by running 'sudo fs_usage | grep Transmit' in a Terminal window while running Transmit.

CAlvarez 12-08-2006 01:17 AM

Good questions.

The name is Carlos-MBP17. I'm really creative. The problem happens with two Debian-based servers. I haven't tried a connection in reverse, but that's a great idea. The Ethereal idea is good too. Hopefully I'll get time to try it tomorrow.

blb 12-08-2006 02:56 AM

(Just a stab in the dark) Do you have anything abnormal in the login scripts for your user on the server to which you are connecting?

hayne 12-08-2006 03:46 AM

Quote:

Originally Posted by blb (Post 340445)
(Just a stab in the dark) Do you have anything abnormal in the login scripts for your user on the server to which you are connecting?

I think this is a very good idea as to a possible cause.
But it would seem that the shell "dot" files (what I assume you mean by "login scripts") would have to contain something which depended on the network connection somehow. How else would this explain the observation that everything works when connected with Ethernet but not with Airport?

CAlvarez 12-08-2006 10:25 AM

Nothing has been done with login scripts on this machine.

blb 12-08-2006 05:28 PM

Quote:

Originally Posted by hayne (Post 340454)
...But it would seem that the shell "dot" files (what I assume you mean by "login scripts")

Yup...
Quote:

Originally Posted by hayne (Post 340454)
would have to contain something which depended on the network connection somehow. How else would this explain the observation that everything works when connected with Ethernet but not with Airport?

I've seen .profiles contain things like using X11's resize (to set COLS/ROWS) which query the xterm being used; if you're logging in remotely, this'll be over the network and if DISPLAY isn't right, strange things can happen. When things aren't quite right, this will cause login delays (though not anywhere near 15 minutes). Why it would do it on one kind of interface but not the other is a very strange issue, but as I said, it was just a stab...

CAlvarez 02-02-2007 08:43 AM

I was researching this issue since it's still plaguing me, and this thread is the only related link in Google...

I've confirmed this to happen with a dozen machines now, running Debian, Ubuntu, CentOS, and others. It happens with a default bare config. The symptoms are always identical; happens only on wireless and with local servers only.

joncraven 02-08-2007 12:56 PM

I'm having the exact same problem, with a fortune printed to the console every time. I do indeed have fortune in my logon scripts, so at least this is a diagnostic tidbit that they are getting executed. My -v output (after authorization) is:

Quote:

debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending command: scp -v -t .
... I want FORTY-TWO TRYNEL FLOATATION SYSTEMS installed within
SIX AND A HALF HOURS!!!
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
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.2 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status 0
Like you I can log on via ssh fine, and on the linux box use scp to copy a file over from the mac, just no scp from the mac to debian directly.

CAlvarez 02-08-2007 02:29 PM

Interesting. I thought I was the only one. Are you on wireless also? Does it work if you are wired?

CAlvarez 02-17-2007 01:48 PM

It gets more interesting...this works fine using a new Airport Extreme, but doesn't work on any other brand of wireless AP that we have tried. It happens to all Core2 type machines with the N wireless card. Time to file a bug I suppose.

gpecke 03-23-2007 06:33 PM

There are two common causes of this sort of behaviour.
1/ Shell scripts which confuse SCP.
2/ More probable. MTU discovery is not working. The link can be
fixed by setting the maximum packet length on the link lower.

jshea 04-17-2007 11:44 AM

Same problem: Cause was .tcsh/iterm startup script
 
I had the same problem, and I found the cause was in my .tcshrc startup scripts. In particular, I was using a script that I think was supplied with iTerm.app or that I found by reading someone else's webpage about configuring iTerm.app. The script sets the title bar in iTerm.app. I changed my .tcshrc to only call the script when in iTerm by doing the following:

if ($TERM_PROGRAM == "iTerm.app") then
source ~/.tcsh/iterm
endif

I hope this helps someone.

joncraven 04-30-2007 04:32 AM

Well, I never did figure out what was causing the problem for me, but I did a full Linux re-install over the weekend and now it works fine. So it must have been something wrong with the Linux config (for what that's worth).

mbpstick 05-28-2007 08:18 PM

I encountered the same problem and discovered I had an 'echo' (used for setting titles in screen) on the remote server that was causing the problem. In .bashrc I had: echo -ne "\ek`hostname`\e\\" ... when this line was removed, scp worked again to my iBook over wireless.

Tomas81 01-19-2009 06:51 PM

Quote:

Originally Posted by mbpstick (Post 382118)
I encountered the same problem and discovered I had an 'echo' (used for setting titles in screen) on the remote server that was causing the problem. In .bashrc I had: echo -ne "\ek`hostname`\e\\" ... when this line was removed, scp worked again to my iBook over wireless.

I had the same problem with my MacBook Pro. I just commented the lines echoing the window title in the .tcshrc file of the remote server and the problem was solved.

Regards


All times are GMT -5. The time now is 07:13 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.