SSH.UserAuthPublicKeyFile
-------------------------

Authenticate a session with a public key, read from a file.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [SSH](component_SSH.md) | [6.3](newinversion63.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "SSH.UserAuthPublicKeyFile"; SSH; UserName; PublicKey; PrivateKey { ; Passphrase } ) 

**MBS**( **"SSH.UserAuthPublicKeyFile";** /\* Authenticate a session with a public key, read from a file. \*/  
**$SSH**; /\* The SSH session reference number from the plugin. \*/   
**$UserName**; /\* user name to authenticate as.e.g. "cs" \*/   
**$PublicKey**; /\* Path of the public key file. (e.g. /etc/ssh/hostkey.pub).   
Optional. Pass empty text if you only have private key.e.g. "/Users/cs/Desktop/id\_rsa.pub" \*/   
**$PrivateKey**; /\* Path of the private key file. (e.g. /etc/ssh/hostkey)e.g. "/Users/cs/Desktop/id\_rsa" \*/   
**$Passphrase**) /\* Optional; Passphrase to use when decoding privatekey.  
Can be empty.e.g. "" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| SSH | The SSH session reference number from the plugin. | $ssh |  |
| UserName | user name to authenticate as. | "cs" |  |
| PublicKey | Path of the public key file. (e.g. /etc/ssh/hostkey.pub).    Optional. Pass empty text if you only have private key. | "/Users/cs/Desktop/id\_rsa.pub" |  |
| PrivateKey | Path of the private key file. (e.g. /etc/ssh/hostkey) | "/Users/cs/Desktop/id\_rsa" |  |
| Passphrase | Passphrase to use when decoding privatekey.   Can be empty. | "" | Optional |

### Result

Returns OK or error.

### Description

Authenticate a session with a public key, read from a file.  
Attempt public key authentication using a PEM encoded private key file stored on disk.  
### Examples

Login with public key:

 Set Variable \[$r ; Value:MBS ( "SSH.UserAuthPublicKeyFile"; $ssh ; SSH::Username ; "your key path"; "your key path"; SSH::Password )\]  
Login with keys:

 Set Variable \[$r ; Value: MBS ( "SSH.UserAuthPublicKeyFile"; $ssh ; SSH::Username ; "/Users/cs/Desktop/id\_rsa.pub"; "/Users/cs/Desktop/id\_rsa"; SSH::Password ) \]  
### See also

- [MongoDB.Connect](MongoDBConnect.md)
- [SQL.Connect](SQLConnect.md)
- [SSH.Tunnel.Run](SSHTunnelRun.md)
- [SSH.UserAuthPublicKey](SSHUserAuthPublicKey.md)

This function checks for a license.

Created 29th May 2016 , last changed 20th June 2016

  
[SSH.UserAuthPublicKey](SSHUserAuthPublicKey.md) - [SSH.WaitClosed](SSHWaitClosed.md)

[HTML Version](SSHUserAuthPublicKeyFile.shtml)