SFTP with .PPK file
Charles Warwick
charles at techstrategies.com.au
Sat Mar 18 04:05:04 EDT 2017
Hi Steve,
Ahh... it's been a while since I wrote the SSH component of tsNet and
I've been unfortunately relying on the documentation I wrote when
checking your code!
tSettings["ssh_private_key"] must provide the "path" to the private key,
not the contents of the private key (another documentation issue for me
to fix!).
So your code should actually look like
on mouseUp
local tHeaders, tResult, tSettings
put “xxxxxxxx" into tSettings["username"]
put "D:\private.ppk" into tSettings["ssh_private_key"]
tsNetInit
put tsNetGet("1", "sftp://secure.xxxxxxxx.us/", tHeaders,
"transferComplete", tSettings) into tResult
end mouseUp
Hopefully that will get it working for you!
Cheers,
Charles
On 17/03/2017 11:36 PM, Stephen MacLean via use-livecode wrote:
> Hi Charles,
>
> Again, thank you for all your help!!
>
> I made the change below, and indeed didn’t get the error any more. However, I still wasn’t getting anything returned.
>
> I ran your debug stack along side it and got this:
>
> Hostname in DNS cache was stale, zapped
> Trying xx.xx.xx.xx...
> TCP_NODELAY set
> Connected to secure.xxxxxxxxxx.us (xx.xx.xx.xx) port 22 (#3)
> SSH MD5 fingerprint: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> SSH authentication methods available: publickey
> Using SSH private key file '-----BEGIN RSA PRIVATE KEY——
> <private key listed>
> -----END RSA PRIVATE KEY-----
> '
> SSH public key authentication failed: Unable to extract public key from private key file: Unable to open private key file
>
> Not sure about were to go from here… I redid the export of the .ppk in PuttyGen and still get the same thing. There is no password protecting the key.
>
> Any further help would be greatly appreciated.
>
> Best Regards,
>
> Steve MacLean
>
>> On Mar 17, 2017, at 5:04 AM, Charles Warwick via use-livecode <use-livecode at lists.runrev.com> wrote:
>>
>> Hi Steve,
>>
>> My apologies... there is a mistake in the documentation for tsNet which I only just noticed.
>>
>> The array element for the SSH private key should be tSettings["ssh_private_key"], not tSettings["ssh_priv_key"].
>>
>> So if you change the following line:
>>
>> put tPrivKey into tSettings["ssh_priv_key"]
>>
>> to:
>>
>> put tPrivKey into tSettings["ssh_private_key"]
>>
>> you should be right to go!
>>
>> (I will get this fixed in the documentation for the next version)
>>
>> Best Regards,
>>
>> Charles
>>
>>
>> On 17/03/2017 6:31 PM, Charles Warwick via use-livecode wrote:
>>> Hi Steve,
>>>
>>> The tsNet command only requires the SSH private key, so that is ok.
>>>
>>> I will test again here to make sure there is nothing else going on in LC 9.0 DP6....
>>>
>>> Just to check though, I assume your private key does not require a passphrase?
>>>
>>> Another thing to try is to download the following simple stack:
>>>
>>> https://downloads.techstrategies.com.au/tsnet/debug_liburl.livecode
>>>
>>> Run that stack at the same time as your own, and click "Start Debug" before you try make the SSH connection.
>>>
>>> It should provide some additional debug information that may shed more light on what is actually happening.
>>>
>>> Regards,
>>>
>>> Charles
>>>
>>>
>>> On 16/03/2017 10:24 PM, Stephen MacLean via use-livecode wrote:
>>>> Hi Charles,
>>>>
>>>> One other thing… in looking at the .ppk file, it contains both “public lines” and "private lines”. All I see in the ssh key file is private.
>>>>
>>>> Not sure that make any difference, but thought I’d mention it.
>>>>
>>>> Best,
>>>>
>>>> Steve
>>>>
>>>>> On Mar 16, 2017, at 7:53 AM, Stephen MacLean via use-livecode <use-livecode at lists.runrev.com> wrote:
>>>>>
>>>>> Hi Charles,
>>>>>
>>>>> Thank you so much for reply!
>>>>>
>>>>> I converted the key file as you described, however, I’m still getting the error 67 (authentication error) when running the script.
>>>>>
>>>>> Any further help would be greatly appreciated.
>>>>>
>>>>> Best,
>>>>>
>>>>> Steve MacLean
>>>>>
>>>>>> On Mar 16, 2017, at 3:08 AM, Charles Warwick via use-livecode <use-livecode at lists.runrev.com> wrote:
>>>>>>
>>>>>> Hi Steve,
>>>>>>
>>>>>> It looks like you are using a SSH private key in PuTTY format (.ppk). tsNet requires it to be in OpenSSH format.
>>>>>>
>>>>>> That is easy to fix though, you can convert the .ppk with PuttyGen.
>>>>>>
>>>>>> To do this, open PuttyGen and load the .ppk file. Then select "Conversions" -> "Export OpenSSH key".
>>>>>>
>>>>>> Apart from that, just make sure that your call to tsNetGet includes the full path of the file you want to download.
>>>>>>
>>>>>> Hope that helps,
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> Charles
>>>>>>
>>>>>>
>>>>>> On 16/03/2017 6:01 AM, Stephen MacLean via use-livecode wrote:
>>>>>>> Well, still no luck in getting it to work, but getting closer…
>>>>>>>
>>>>>>> I found a sample file linked to on livecode.com <http://livecode.com/>. Modifying it to use the key file, I have:
>>>>>>>
>>>>>>> on mouseUp
>>>>>>> local tHeaders, tResult, tSettings
>>>>>>> put “xxxxxxxx" into tSettings["username"]
>>>>>>> put URL "binfile:D:\private.ppk" into tPrivKey
>>>>>>> put tPrivKey into tSettings["ssh_priv_key"]
>>>>>>> tsNetInit
>>>>>>> put tsNetGet("1", "sftp://secure.xxxxxxxx.us/", tHeaders, "transferComplete", tSettings) into tResult
>>>>>>> end mouseUp
>>>>>>>
>>>>>>> However, it returns:
>>>>>>>
>>>>>>> tsneterr: (67) Authentication failure
>>>>>>>
>>>>>>> Again, I can access the sftp site with no problems using the WinSCP ftp client and the key file.
>>>>>>>
>>>>>>> Any suggestions??
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> Steve MacLean
>>>>>>>
>>>>>>>> On Mar 15, 2017, at 9:38 AM, Stephen MacLean via use-livecode <use-livecode at lists.runrev.com> wrote:
>>>>>>>>
>>>>>>>> Hi All,
>>>>>>>>
>>>>>>>> Looking to use tsNet to connect to a SFTP server that uses username and a private key instead of a password. The private key is contained in a file.
>>>>>>>>
>>>>>>>> I use WinSCP and can link the connection to the file and can connect fine.
>>>>>>>>
>>>>>>>> In LC, I’ve set the CABundle to the file, but am not sure this is how it’s supposed to work. Getting an auth error when doing tsNetGet.
>>>>>>>>
>>>>>>>> Any help would be appreciated.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>>
>>>>>>>> Steve MacLean
>>>>>>>>
>>>>>>>> PS: Running 9.0 dp6 Business
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> use-livecode mailing list
>>>>>>>> use-livecode at lists.runrev.com
>>>>>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>>> _______________________________________________
>>>>>>> use-livecode mailing list
>>>>>>> use-livecode at lists.runrev.com
>>>>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>> _______________________________________________
>>>>>> use-livecode mailing list
>>>>>> use-livecode at lists.runrev.com
>>>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>
>>>>> _______________________________________________
>>>>> use-livecode mailing list
>>>>> use-livecode at lists.runrev.com
>>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> use-livecode at lists.runrev.com
>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list