SSH connector
The SSH connector is an implementation of the Scripted Groovy connector toolkit based on Java Secure Channel (JSch) and the Java implementation of the Expect library (Expect4j). This connector lets you interact with any SSH server, using Groovy scripts for the ICF operations.
The SSH connector is a poolable connector. This means that each connector instance is placed into a connection pool every time an action is completed. Subsequent actions can re-use connector instances from the connector pool. When a new connector instance is created, a new SSH client connection is created against the target SSH server. This SSH connection remains open as long as the connector instance is in the connection pool. Note that when a new action is performed, it finds the SSH connection in the exact state that it was left by the previous action.
The following image shows the relationship between SSH connector instances and SSH connections to the target server:
Configure authentication to the SSH server
The SSH connector authenticates to the SSH server using either a login/password or a public/private key. The authentication method is specified in the authenticationType
property in the connector configuration.
- Authenticate with a login and password
-
To authenticate with a login and password, set the
authenticationType
toPASSWORD
in the connector configuration file, and set auser
andpassword
. For example:"configurationProperties" : { ... "authenticationType" : "PASSWORD", "user" : "<USERNAME>", "password" : "<PASSWORD>", ...
The password is encrypted when IDM loads the provisioner file.
- Authenticate with a passphrase and private key
-
To authenticate with a secure certificate, generate a pair of public/private keys. Install the public key on the server side and the private key on the IDM host (where the connector is located). Set the
authenticationType
toPUBKEY
in the connector configuration file and set theuser
,password
,passphrase
andprivateKey
properties. For example:"configurationProperties" : { ... "authenticationType" : "PUBKEY", "user" : "<USERNAME>", "password" : "<PASSWORD>", "passphrase" : "secret", "privateKey" : ["-----BEGIN DSA PRIVATE KEY-----", "MIIBugIBAAKBgQDcB0ztVMCFptpJhqlLNZSdN/5cDL3S7aOVy52Ae7vwwCqQPCQr", "6NyUk+wtkDr07NlYd3sg7a9hbsEnlYChsuX+/WUIvbOKdMfeqcQ+jKK26YdkTCGj", "g86dBj9JYhobSHDoQ9ov31pYN/cfW5BAZwkm9TdpEjHPvMIaOxx7GPGKWwIVALbD", "CEuf1yJk9UB7v0dmJS7bKkbxAoGARcbAuDP4rB6MsgAAkVwf+1sHXEiGPShYWrVV", "qBgCZ/S45ELqUuiaN/1N/nip/Cc/0SBPKqwl7o50CUg9GH9kTAjmXiwmbkwvtUv+", "Xjn5vCHS0w18yc3rGwyr2wj+D9KtDLFJ8+T5HmsbPoDQ3mIZ9xPmRQuRFfVMd9wr", "DY0Rs7cCgYAxjGjWDSKThowsvOUCiE0ySz6tWggHH3LTrS4Mfh2t0tnbUfrXq2cw", "3CN+T6brgnpYbyX5XI17p859C+cw90MD8N6vvBxaN8QMDRFk+hHNUeSy8gXeem9x", "O0vdIxCgKvA4dh5nSVb5VGKENEGNEHRlYxEPzbqlPa/C/ZvzIvdKXQIUQMoidPFC", "n9z+mE2dAADnPf2m9vk=", "-----END DSA PRIVATE KEY-----" ], ...
The default value for the
passphrase
property isnull
. If you do not set a passphrase for the private key, the passphrase value must be equal to an empty string.You must set a value for the
password
property, because the connector uses sudo to perform actions on the SSH server.The private key (PEM certificate) must be defined as a JSON String array.
The values of the
passphrase
,password
andprivateKey
are encrypted when IDM loads the provisioner file.
Install the SSH connector
If you are looking for the Advanced Identity Cloud application for this connector, refer to: |
You can download any connector from Backstage, but some are included in the default deployment for Advanced Identity Cloud, IDM, or RCS. When using an included connector, you can skip installing it and move directly to configuration.
Connector | IDM | RCS |
---|---|---|
Yes |
Yes |
Download the connector .jar file from Backstage.
-
If you are running the connector locally, place it in the
/path/to/openidm/connectors
directory, for example:mv ~/Downloads/ssh-connector-1.5.20.26.jar /path/to/openidm/connectors/
-
If you are using a remote connector server (RCS), place it in the
/path/to/openicf/connectors
directory on the RCS.
Configure the SSH connector
You cannot configure the SSH connector through the UI. Configure the connector over REST, as described in Configure Connectors Over REST.
Alternatively, copy the sample connector configuration file (/path/to/openidm/samples/example-configurations/provisioners/provisioner.openicf-ssh.json
) to your project’s conf/
directory, and edit it to match your environment.
Set the authentication properties, as described in Configure Authentication to the SSH Server. In addition, set at least the following properties:
host
-
Specify the hostname or IP address of the SSH server.
port
-
Set the port on which the SSH server listens.
Default:
22
user
-
The username of the account that connects to the SSH server.
This account must be able to
ssh
into the server, with the password provided in the next parameter. password
-
The password of the account that is used to connect to the SSH server.
prompt
-
A string representing the remote SSH session prompt. This must be the exact prompt string, in the format
username@target:
, for exampleadmin@myserver:~$
. Include any trailing spaces.
This list describes the required configuration properties of the SSH connector. Typically, you can use the default values. For a list of all the configuration properties, refer to SSH Connector Configuration
sudoCommand
-
A string that shows the full path to the
sudo
command, for example/usr/bin/sudo
. echoOff
-
If set to
true
(the default), the input command echo is disabled. If set tofalse
, every character that is sent to the server is sent back to the client in theexpect()
call. terminalType
-
Sets the terminal type to use for the session. The list of supported types is determined by your Linux/UNIX system. For more information, refer to the
terminfo
manual page (man terminfo
).Default:
vt102
setLocale
-
If set to
true
, indicates that the default environment locale should be changed to the value of thelocale
property.Default:
false
locale
-
Sets the locale for the LC_ALL, LANG and LANGUAGE environment variables, if
setLocale
is set totrue
.Default:
en_US.utf8
connectionTimeout
-
Specifies the connection timeout to the remote server, in milliseconds.
Default:
5000
expectTimeout
-
Specifies the timeout used by the
expect()
calls in scripts, in milliseconds.Default:
5000
authenticationType
-
Sets the authentication type, either
PASSWORD
orPUBKEY
. For more information, refer to Configure authentication to the SSH server.Default:
PASSWORD
throwOperationTimeoutException
-
If
true
, the connector throws an exception when theexpectTimeout
is reached for an operation. Otherwise, the operation fails silently.Default:
true
scriptRoots
-
The path to the Groovy scripts that perform the ICF operations, relative to your IDM installation directory. The sample connector configuration expects the scripts in
project-dir/tools
, so this parameter is set to&{idm.instance.dir}/tools
in the sample configuration. classpath
-
The directory in which the compiler should look for compiled classes. The default classpath, if not is specified, is
install-dir/lib
. *ScriptFileName
-
The name of the Groovy script that is used for each ICF operation.
SSH remote connector
If you want to run this connector outside of PingOne Advanced Identity Cloud or IDM, you can configure the SSH connector as a remote connector. Java Connectors installed remotely on a Java Connector Server function identically to those bundled locally within PingOne Advanced Identity Cloud or installed locally on IDM.
You can download the SSH connector from here.
Refer to Remote connectors for configuring the SSH remote connector.
OpenICF Interfaces Implemented by the SSH Connector
The SSH Connector implements the following OpenICF interfaces. For additional details, see ICF interfaces:
- Authenticate
-
Provides simple authentication with two parameters, presumed to be a user name and password.
- Create
-
Creates an object and its
uid
. - Delete
-
Deletes an object, referenced by its
uid
. - Resolve Username
-
Resolves an object by its username and returns the
uid
of the object. - Schema
-
Describes the object types, operations, and options that the connector supports.
- Script on Connector
-
Enables an application to run a script in the context of the connector.
Any script that runs on the connector has the following characteristics:
-
The script runs in the same execution environment as the connector and has access to all the classes to which the connector has access.
-
The script has access to a
connector
variable that is equivalent to an initialized instance of the connector. At a minimum, the script can access the connector configuration. -
The script has access to any script arguments passed in by the application.
-
- Script on Resource
-
Runs a script on the target resource that is managed by this connector.
- Search
-
Searches the target resource for all objects that match the specified object class and filter.
- Sync
-
Polls the target resource for synchronization events, that is, native changes to objects on the target resource.
- Test
-
Tests the connector configuration.
Testing a configuration checks all elements of the environment that are referred to by the configuration are available. For example, the connector might make a physical connection to a host that is specified in the configuration to verify that it exists and that the credentials that are specified in the configuration are valid.
This operation might need to connect to a resource, and, as such, might take some time. Do not invoke this operation too often, such as before every provisioning operation. The test operation is not intended to check that the connector is alive (that is, that its physical connection to the resource has not timed out).
You can invoke the test operation before a connector configuration has been validated.
- Update
-
Updates (modifies or replaces) objects on a target resource.
SSH Connector Configuration
The SSH Connector has the following configurable properties:
Basic Configuration Properties
Property | Type | Default | Encrypted(1) | Required(2) |
---|---|---|---|---|
|
|
|
|
Yes |
The hostname to connect to. |
||||
|
|
|
|
Yes |
TCP port to use. |
||||
|
|
|
|
Yes |
The user name used to login to remote server. |
||||
|
|
|
Yes |
No |
The password used to login to remote server. |
||||
|
|
|
Yes |
No |
The passphrase used to read the private key when using Public Key authentication. |
||||
|
|
|
Yes |
No |
The base 64 encoded value (PEM) of the private key used for Public Key authentication. |
||||
|
|
|
|
Yes |
Defines which authentication type should be use: PASSWORD or PUBKEY. |
||||
|
|
`root@localhost:# ` |
|
Yes |
A string representing the remote SSH session prompt. |
||||
|
|
|
|
Yes |
A string representing the sudo command. |
||||
|
|
|
|
Yes |
Disable the input command echo. |
||||
|
|
|
|
Yes |
Defines the terminal type to use for the session. |
||||
|
|
|
|
Yes |
Define the locale for LC_ALL, LANG and LANGUAGE environment variables to use if setLocale=true. |
||||
|
|
|
|
Yes |
Defines if the default environment locale should be changed with the value provided for locale. |
||||
|
|
|
|
Yes |
Defines the connection timeout to the remote server in milliseconds. |
||||
|
|
|
|
Yes |
Defines the timeout used by the expect() calls in the scripts in milliseconds. |
||||
|
|
|
|
Yes |
Defines if an OperationTimeoutException should be thrown if any call to expect times out. |
||||
|
|
|
|
No |
Defines the "prompt ready" timeout for the promptReady() command in milliseconds. |
(1) Whether the property value is considered confidential, and is therefore encrypted in IDM.
(2) A list of operations in this column indicates that the property is required for those operations.
Groovy Engine configuration
Property | Type | Default | Encrypted(1) | Required(2) |
---|---|---|---|---|
|
|
|
|
Yes |
The root folder to load the scripts from. If the value is null or empty the classpath value is used. |
||||
|
|
|
|
No |
Classpath for use during compilation. |
||||
|
|
|
|
No |
If true, debugging code should be activated. |
||||
|
|
|
|
No |
Sets a list of global AST transformations which should not be loaded even if they are defined in META-INF/org.codehaus.groovy.transform.ASTTransformation files. By default, none is disabled. |
||||
|
|
|
|
No |
Sets the minimum of time after a script can be recompiled. |
||||
|
|
|
|
No |
If set to true recompilation is enabled. |
||||
|
|
|
|
No |
Base class name for scripts (must derive from Script). |
||||
|
|
|
|
No |
Gets the extensions used to find groovy files. |
||||
|
|
|
|
No |
Encoding for source files. |
||||
|
|
|
|
No |
Directory into which to write classes. |
||||
|
|
|
|
No |
The error tolerance, which is the number of non-fatal errors (per unit) that should be tolerated before compilation is aborted. |
||||
|
|
|
|
No |
If true, the compiler should produce action information. |
||||
|
|
|
|
No |
Warning Level of the compiler. |
||||
|
|
|
|
No |
Custom Configuration script for Groovy ConfigSlurper. |
||||
|
|
|
Yes |
No |
Custom Sensitive Configuration script for Groovy ConfigSlurper. |
(1) Whether the property value is considered confidential, and is therefore encrypted in IDM.
(2) A list of operations in this column indicates that the property is required for those operations.
Operation Script Files
Property | Type | Default | Encrypted(1) | Required(2) |
---|---|---|---|---|
|
|
|
|
|
The name of the file used to perform the AUTHENTICATE operation. |
||||
|
|
|
|
|
The name of the file used to perform the CREATE operation. |
||||
|
|
|
|
No |
The script used to customize some function of the connector. Read the documentation for more details. |
||||
|
|
|
|
|
The name of the file used to perform the DELETE operation. |
||||
|
|
|
|
|
The name of the file used to perform the RESOLVE_USERNAME operation. |
||||
|
|
|
|
|
The name of the file used to perform the SCHEMA operation. |
||||
|
|
|
|
|
The name of the file used to perform the RUNSCRIPTONRESOURCE operation. |
||||
|
|
|
|
|
The name of the file used to perform the SEARCH operation. |
||||
|
|
|
|
|
The name of the file used to perform the SYNC operation. |
||||
|
|
|
|
|
The name of the file used to perform the TEST operation. |
||||
|
|
|
|
|
The name of the file used to perform the UPDATE operation. |
(1) Whether the property value is considered confidential, and is therefore encrypted in IDM.
(2) A list of operations in this column indicates that the property is required for those operations.