0

I'm new to Linux, so I may be a bit unfamiliar with the terminologies used here, but what I'm trying to do now is from a Windows PC, I would use plink to ssh into a Linux server and use sudo to run as another user to copy a file from a remote location to local.  E.g.,

from a Windows machine A: plink testadmin@linuxserverB.com "sudo -u user_a python /tools/copyfile.py remoteserverC.com:/a/b/c/filetocopy.txt /local/targetfile.txt"

  • where both linuxserverB and remoteserverC is Linux
  • python script would accept 2 param argument and calls scp to copy, first is source and next is destination to copy

I would get Disconnected: Protocol error (Too many authentication failures for user_a). Child process (ssh) exited with code 78)

A few things I noticed:

  1. If I use plink to do the same call but source and target changed to only copy files within /local To ‘/local/‘,(linuxserverB ) there will be no issues.  It only happens if I try to access a file from remoteserverC.com like the original example.

  2. I tried using the same command as ssh instead of plink on another Linux machine (Linux D), and doing a verbose dump, I see that I would get almost the same error:

    X11 connection uses different authentication protocol.
    X11 connection rejected because of wrong authentication.
    ..
    Unable to open display linuxserverB.com:123.0 Disconnected. Protocol error (Too many authentication failures for user_a)
    
  3. So I thought it may be due to X11 forwarding issues, although I'm not too familiar with this concept. Basically I tried using -X on the plink and would get:
    Putty X11 proxy: wrong authorisation protocol attemptedUnable to open display linuxserverB.com:123.0 ... Disconnected: Protocol error (Too many authentication failures for user_a)
    
  4. I tried using xauth to add the displays on both remoteserverC.com and linuxserverB.com so that both remoteserverC.com and linuxserverB.com contains each other's display id but the problem still persists.

  5. I also tried installing XMing on the Windows machine A, and was able to do a plink of xeyes successfully.

So I'm not too sure what is wrong. Is there any other thing that I can try? Is the issue due to X11 forwarding display location or due to .XAuthority issues?

  • (1) Please be clearer about what machines you are working with and what operating systems they are using.  I think I see three machines: “Windows machine A”, “windowsserver.com” and “remoteserver.com”.  It might help if you called them A, B and C, and then stated what OSs they run.  (For example, I guess you mean “I’m physically logged in to machine A, and I want to use plink to ssh into B and then copy a file from C to B.” in your first paragraph.) … (Cont’d) – Scott Jul 22 at 17:33
  • (Cont’d) …  And try to be clearer about what commands you type on what machines and what responses you get.  (And please try to report the responses accurately.  I doubt that you really got an error message with “attemptedUnable” as one word.)  (1b) But I’m confused.  You say “I would use plink to ssh into a Linux server and use sudo …”, but then you say plink testadmin@windowsserver.com "sudo …".  (1c) What OS is  “remoteserver.com” running?  (1d) Oh, wait; what is “a Linux PC” and how does it fit in? … (Cont’d) – Scott Jul 22 at 17:33
  • (Cont’d) …  (2) Can you get an interactive shell on machine B by running ssh B, plink B, or using PuTTY?  If so, try running your “copyfile” command from there, so it’s clearer what command causes what error.  (2b) Why aren’t you using scp?  (3) Why are you talking about X11?  For simply copying files, X shouldn’t be a factor. … … … … … … … … … … … … … … Please do not respond in comments; edit your question to make it clearer and more complete. – Scott Jul 22 at 17:33
  • Sorry, I typed the question at midnight I must’ve been too sleepy. I’ve made corrections and put in more details and updated all references to prevent confusion. Basically after logging into windows A, plink into linuxserverB to run a python script to scp file from remoteserverC to linuxserverB. – adrive Jul 22 at 23:11
  • If you are using sudo, then you'd need to enter a password right? Can you open an interactive ssh session, then run the command? Presumably that would give you a password prompt, which might be missing when you send the command directly? – Sparhawk Jul 22 at 23:20
0

Yes, the message seems to be from remoteserverC.

You're using plink to connect as testadmin to linuxserverB and running a script with sudo -u user_a there. So the script will be running as user_a@linuxserverB.

Since the scp target specification does not include an username, the scp command embedded within the perl script will be trying to connect to user_a@remoteserverC. Apparently either the username is wrong or the appropriate keys are not available for that (or there are more keys available on the connection than the number of authentication attempts allowed by remoteserverC).

First question is, does user_a@remoteserverC make sense? If user_a does not exist on remoteserverC, then your copy source specification needs to include an username for remoteserverC, such as some_other_user@remoteserverC.com:/a/b/c/filetocopy.txt.

If that does not solve the problem, check the logs on remoteserverC and find out what kind of authentication attempts are being rejected and why. Perhaps the user's ~/.ssh/authorized_keys file is insufficiently protected on remoteserverC and the server's sshd daemon is disregarding the list of authorized keys as a result. The authorized_keys file needs to be protected so that only the user itself (or root) can write to it. If that's the case, the log message should indicate the file or directory whose permissions sshd is unhappy about.

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.