CURL.SetOptionSSHPrivateKeyfile
-------------------------------

Sets the file path for your private key.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [CURL](component_CURL.md) | [2.5](newinversion25.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "CURL.SetOptionSSHPrivateKeyfile"; curl; Value { ; Encoding } ) 

**MBS**( **"CURL.SetOptionSSHPrivateKeyfile";** /\* Sets the file path for your private key. \*/  
**$curl**; /\* The CURL session handle. \*/   
**$Value**; /\* The new file path.e.g. "c:\\myprivatekey" \*/   
**$Encoding**) /\* Optional; The text encoding for text parameter.   
Default is UTF-8.e.g. "UTF8" \*/ 

### 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](https://www.monkeybreadsoftware.com/filemaker/faq.shtml). | "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](CURLSetOptionKeyPassword.md).  
  
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](CURLSetOptionSSHAuthTypes.md), which needs to include flag 1 (CURLSSH\_AUTH\_PUBLICKEY) and you may need to use [CURL.SetOptionKeyPassword](CURLSetOptionKeyPassword.md) to provide password for key file if needed.  
See also [SSH\_PRIVATE\_KEYFILE](https://curl.haxx.se/libcurl/c/CURLOPT_SSH_PRIVATE_KEYFILE.html) option in CURL manual.

### Examples

Login via SSH with public key:

 Set Variable \[ $curl ; Value: MBS ("[CURL.New](CURLNew.md)") \]   
Set Variable \[ $result ; Value: MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)"; $curl ; "sftp://test.com:1222/test.fmp12" ) \]   
Set Variable \[ $result ; Value: MBS ("[CURL.SetOptionVerbose](CURLSetOptionVerbose.md)"; $curl ; 1) \]   
Set Variable \[ $result ; Value: MBS ("[CURL.SetOptionUpload](CURLSetOptionUpload.md)"; $curl ; 1) \]   
Set Variable \[ $result ; Value: MBS ("[CURL.SetOptionConnectionTimeout](CURLSetOptionConnectionTimeout.md)"; $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](CURLSetOptionSSHPublicKeyfile.md)"; $curl ; "/Users/jameykey/.ssh/id\_rsa.pub") \]   
Set Variable \[ $result ; Value: MBS ("[CURL.SetOptionUserName](CURLSetOptionUserName.md)"; $curl ; CURL Test::Name ) \]   
\#   
\# no password with private key!   
// Set Variable \[ $result ; Value: MBS ("[CURL.SetOptionPassword](CURLSetOptionPassword.md)"; $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](CURLSetInputText.md)"; $curl ; $d ) \]   
// Set Variable \[ $result ; Value: MBS ("[CURL.OpenInputFile](CURLOpenInputFile.md)"; $curl ; "/Users/test/Desktop/test.fmp12") \]   
\#   
\# do it!   
Set Field \[ CURL Test::Result ; MBS ("[CURL.Perform](CURLPerform.md)"; $curl ) \]   
Set Field \[ CURL Test::debug ; MBS ("[CURL.GetDebugMessages](CURLGetDebugMessages.md)"; $curl ) \]   
Set Variable \[ $result ; Value: MBS ("[CURL.Release](CURLRelease.md)"; $curl ) \]  
### See also

- [CURL.New](CURLNew.md)
- [CURL.OpenInputFile](CURLOpenInputFile.md)
- [CURL.Perform](CURLPerform.md)
- [CURL.Release](CURLRelease.md)
- [CURL.SetOptionConnectionTimeout](CURLSetOptionConnectionTimeout.md)
- [CURL.SetOptionKeyPassword](CURLSetOptionKeyPassword.md)
- [CURL.SetOptionSSHAuthTypes](CURLSetOptionSSHAuthTypes.md)
- [CURL.SetOptionURL](CURLSetOptionURL.md)
- [CURL.SetOptionUserName](CURLSetOptionUserName.md)
- [CURL.SetOptionVerbose](CURLSetOptionVerbose.md)

### Release notes

- **Version 8.0**
    - Changed [CURL.SetOptionCAINFO](http://www.mbsplugins.eu/CURLSetOptionCAINFO.shtml), [CURL.SetOptionCAPATH](http://www.mbsplugins.eu/CURLSetOptionCAPATH.shtml), [CURL.SetOptionCookieFile](http://www.mbsplugins.eu/CURLSetOptionCookieFile.shtml), [CURL.SetOptionCookieJar](http://www.mbsplugins.eu/CURLSetOptionCookieJar.shtml), [CURL.SetOptionIssuerCert](http://www.mbsplugins.eu/CURLSetOptionIssuerCert.shtml), [CURL.SetOptionNETRCFile](http://www.mbsplugins.eu/CURLSetOptionNETRCFile.shtml), [CURL.SetOptionRandomFile](http://www.mbsplugins.eu/CURLSetOptionRandomFile.shtml), [CURL.SetOptionSSHPrivateKeyfile](http://www.mbsplugins.eu/CURLSetOptionSSHPrivateKeyfile.shtml), [CURL.SetOptionSSHPublicKeyfile](http://www.mbsplugins.eu/CURLSetOptionSSHPublicKeyfile.shtml), [CURL.SetOptionSSLCert](http://www.mbsplugins.eu/CURLSetOptionSSLCert.shtml), [CURL.SetOptionSSLKey](http://www.mbsplugins.eu/CURLSetOptionSSLKey.shtml) 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

- [MBS FileMaker Plugin, version 7.6pr3](https://www.mbsplugins.de/archive/2017-12-13/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)

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

  
[CURL.SetOptionSSHKnownHosts](CURLSetOptionSSHKnownHosts.md) - [CURL.SetOptionSSHPublicKeyfile](CURLSetOptionSSHPublicKeyfile.md)

[HTML Version](CURLSetOptionSSHPrivateKeyfile.shtml)