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
MBS( "CURL.SetOptionSSHPrivateKeyfile"; curl; Value { ; Encoding } )   More

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

Release notes

Blog Entries

Created 18th August 2014, last changed 17th February 2022


CURL.SetOptionSSHKnownHosts - CURL.SetOptionSSHPublicKeyfile

💬 Ask a question or report a problem