Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
CURL.SetOptionSSHPrivateKeyfile
Sets the file path for your private key.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
CURL | 2.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
curl | The CURL session handle. | $curl | |
Value | The new file path. | "c:\myprivatekey" | |
Encoding | The text encoding for text parameter. Default is UTF-8. Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the FAQ. |
"UTF8" | Optional |
Result
Returns "OK" on success.
Description
Sets the file path for your private key.If not used, libcurl defaults to using ~/.ssh/id_dsa. If the file is password-protected, set the password with CURL.SetOptionKeyPassword.
For a SFTP transfer (= file transfer over SSH), you would tell the plugin your public and private keys, so the plugin can login.
If you Putty to connect and you like to export the key from there, please export as "Export OpenSSH Key" type.
See also CURL.SetOptionSSHAuthTypes, which needs to include flag 1 (CURLSSH_AUTH_PUBLICKEY) and you may need to use CURL.SetOptionKeyPassword to provide password for key file if needed.
See also SSH_PRIVATE_KEYFILE option in CURL manual.
Examples
Login via SSH with public key:
Set Variable [ $curl ; Value: MBS("CURL.New") ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionURL"; $curl; "sftp://test.com:1222/test.fmp12" ) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionVerbose"; $curl; 1) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionUpload"; $curl; 1) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionConnectionTimeout"; $curl; 10) ]
#
# specify paths to keys, public key optional as it is usually included in private key file:
Set Variable [ $result ; Value: MBS("CURL.SetOptionSSHPrivateKeyfile"; $curl; "/Users/jameykey/.ssh/id_rsa") ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionSSHPublicKeyfile"; $curl; "/Users/jameykey/.ssh/id_rsa.pub") ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionUserName"; $curl; CURL Test::Name) ]
#
# no password with private key!
// Set Variable [ $result ; Value: MBS("CURL.SetOptionPassword"; $curl; CURL Test::Password) ]
#
# upload text or open a file path
Set Variable [ $d ; Value: "Just a little bit text. Have fun!" ]
Set Variable [ $result ; Value: MBS("CURL.SetInputText"; $curl; $d) ]
// Set Variable [ $result ; Value: MBS("CURL.OpenInputFile"; $curl; "/Users/test/Desktop/test.fmp12") ]
#
# do it!
Set Field [ CURL Test::Result ; MBS("CURL.Perform"; $curl) ]
Set Field [ CURL Test::debug ; MBS("CURL.GetDebugMessages"; $curl) ]
Set Variable [ $result ; Value: MBS("CURL.Release"; $curl) ]
See also
- CURL.New
- CURL.OpenInputFile
- CURL.Perform
- CURL.Release
- CURL.SetOptionConnectionTimeout
- CURL.SetOptionKeyPassword
- CURL.SetOptionSSHAuthTypes
- CURL.SetOptionURL
- CURL.SetOptionUserName
- CURL.SetOptionVerbose
Release notes
- Version 8.0
- Changed CURL.SetOptionCAINFO, CURL.SetOptionCAPATH, CURL.SetOptionCookieFile, CURL.SetOptionCookieJar, CURL.SetOptionIssuerCert, CURL.SetOptionNETRCFile, CURL.SetOptionRandomFile, CURL.SetOptionSSHPrivateKeyfile, CURL.SetOptionSSHPublicKeyfile, CURL.SetOptionSSLCert, CURL.SetOptionSSLKey to use always UTF-8 on Mac/Linux and on Mac do the unicode transformation for decomposed characters to avoid trouble with special characters in file paths.
Blog Entries
Created 18th August 2014, last changed 17th February 2022
CURL.SetOptionSSHKnownHosts - CURL.SetOptionSSHPublicKeyfile