Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

getting sftp to work with 2 different platforms and keypairs

by Aldebaran (Curate)
on Sep 06, 2019 at 18:41 UTC ( [id://11105737]=perlquestion: print w/replies, xml ) Need Help??

Aldebaran has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,

I know I have another thread going where I am OP, but I have an unrelated matter I wanted to address. I'm trying to port my perl html template to windows, and the spot that is sticking is establishing sftp.

I'm using PuTTy and PuTTyGen to create the key pairs.

Here's the rub. I still want perl to be able to sftp to this server with my old linux machine. I want perl to be able to do it from windows as well. So we're to look at a file in the .ssh directory called authorized_keys . When I got the public key from putty, I appended it to this file, providing one line of whitespace. (It occurs to me that my C impulse to leave whitespace isn't a sound one in the unix environment.)

Now, my old machine can log in, but on PuTTy, when I go SSH--->Auth-->Browse to the private key, I do not succeed. Specifically:

Server refused our key

I thought that installing IO::Pty might do something for me, but this doesn't achieve anything:

Configuring T/TO/TODDR/IO-Tty-1.12.tar.gz with Makefile.PL This module requires a POSIX compliant system to work. Try cygwin if y +ou need this module on windows OS unsupported at Makefile.PL line 6. Warning: No success on command[C:\Strawberry\perl\bin\perl.exe Makefil +e.PL] TODDR/IO-Tty-1.12.tar.gz C:\Strawberry\perl\bin\perl.exe Makefile.PL -- NOT OK Stopping: 'install' failed for 'IO::Pty'. Failed during this command: TODDR/IO-Tty-1.12.tar.gz : writemakefile NO 'C:\S +trawberry\perl\bin\perl.exe Makefile.PL' returned status 65280 cpan>

Grateful for any tips and tricks,

Replies are listed 'Best First'.
Re: getting sftp to work with 2 different platforms and keypairs (maybe OT)
by hippo (Bishop) on Sep 06, 2019 at 19:57 UTC
    Now, my old machine can log in, but on PuTTy, when I go SSH--->Auth-->Browse to the private key, I do not succeed.

    It sounds from this like you are unable to perform an ssh key-authenticated login from Windows even without Perl. I'm not sure what relevance Perl has to this problem. Can you explain more?

Re: getting sftp to work with 2 different platforms and keypairs
by atcroft (Abbot) on Sep 06, 2019 at 22:51 UTC

    To make sure I am understanding correctly, I will try restating your problem:

    1. You have an existing key pair used by your "old linux machine".
    2. You created a key pair using PuTTY and PuTTYGen.
    3. You appended a blank line followed by the public key from PuTTYGen to ~/.ssh/authorized_keys.
    4. Old key works, new key fails.
    Sound about right?

    My initial troubleshooting of this issue would be along the following lines:

    1. First of all, I do not believe the blank line is the issue. (I tested this on my own system, and it did not seem to affect it.) You can also make the blank line a comment with a leading '#', just to see if that makes a difference. (I doubt it will, however.)
    2. Next, I would verify that the public key you entered into the authorized_keys file is present in its entirety. Assuming you copied the public key from the PuTTYGen interface, make sure that you copied the entire key from the window. (I have seen experienced admins get caught by this.) One way to ensure you all of it is to add a key comment, and verify that it is present in the public key string. (Also not a bad idea, so you can easily identify this key from others.)
    3. I would then verify that the key is a single line entry in the authorized_keys file. (Personally, I would probably move down the file in vi, but whatever way works for you.)

    If that did not work, then I would begin looking at (or talking to someone who could look at) the logs on the server, to see if there is anything there that provided the next clue.

    As far as the perl script on the Windows machine accessing the server, it is my understanding that can be problematic at best, so I would start by verifying your new key is working in PuTTY before tackling that.

    Hope that helps.

Re: getting sftp to work with 2 different platforms and keypairs
by johngg (Canon) on Sep 06, 2019 at 20:32 UTC

    This might not be relevant but I recall that back in the world of $work I could never get keys generated with PuTTyGen to connect via SSH/SFTP to the Linux/Unix servers I was supporting. Installing Cygwin and using keys generated with the ssh-keygen that came with with it worked fine. This was on WIndows XP and Windows 7 laptops/desktops. I've been retired for a few years now so this info may be out of date.

    Cheers,

    JohnGG

      I recall that back in the world of $work I could never get keys generated with PuTTyGen to connect via SSH/SFTP to the Linux/Unix servers I was supporting

      Odd, I've been using puttygen-generated keys to connect from at least Win7 and now Win10 to a variety of linux systems since at least 2013 ... and probably even before that; that's just the date of the oldest key I still have a record for; I may have even started on XP (I'm not sure, but I held out on XP for a long time before going to Win7). My current key is RSA key, using 4096 bits.

      Unlike Aldebaran, I don't hardlink to the key; I have used pageant (or a pageant-compatible key agent plugin in my password manager), and that works just fine. But I cannot imagine that putty has difficulty with files but not with a third-party pageant-clone.

      Like hippo, I think this doesn't have so much to do with perl (yet)... though since the next step after getting the keypairs working will be to try to connect using perl, and we'll probably be asked to help with that after this is working, it's a good starting point to have confirmation that Aldebaran can connect using putty directly... and then support of the perl connection can continue in the same thread. :-)

        Like hippo, I think this doesn't have so much to do with perl (yet)... though since the next step after getting the keypairs working will be to try to connect using perl, and we'll probably be asked to help with that after this is working, it's a good starting point to have confirmation that Aldebaran can connect using putty directly... and then support of the perl connection can continue in the same thread. :-)

        Let me first address the topicality. At this point, I'm addressing things that are implementation specific in a couple ways. First is that I am on the windows platform. It's truly one of the bummers of the windows platform that I have to fight to make this happen. Also, I wouldn't want bliako to think that I've lost faith in unix. The truth is that I would install a dual boot ubuntu, but I can't get the darn thing to restart cold and look at the thumb drive. So I have to live in windowsland on my nice new machine for the time being.

        Additionally, this question is implementation specific in that it considers Strawberry Perl first. I took soonix's downthread advice and installed Git, and with the way perl is behaving, I'm genuinely confused. For those uninterested in this implementation-specific problem, I invite you to skip the content between the readmore tags (maybe the entire thread if you're tired of posts about getting strawberry perl configured):

        Fishing for tips,

Re: getting sftp to work with 2 different platforms and keypairs
by soonix (Canon) on Sep 07, 2019 at 11:04 UTC
    In cases of compatibility (or negotiation) problems between putty and hosts, I switch to the ssh command of Git BASH (included in Git for Windows). This has the additional advantage, that its syntax (and how to generate/add/... keys) is the same as under Linux.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11105737]
Approved by Paladin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-26 05:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found