SSH 登录
使用 SSH 协议来启动与远程服务器的连接。
命令可用性: 本地 IBM RPA SaaS 和 IBM RPA
描述
根据服务器、用户、密码和认证密钥等配置指令,使用 SSH 协议启动与远程服务器的连接。
脚本语法
IBM RPA 的专有脚本语言的语法与其他编程语言类似。 该脚本语法在脚本文件中定义命令的语法。 您可以在 IBM RPA Studio的 脚本 方式下使用此语法。
startSSH --host(String) --username(String) [--password(String)] [--port(Numeric)] --keygen(String) [--passphrase(String)] [--timeout(TimeSpan)] (SSHSession)=value
输入参数
下表显示了此命令中提供的输入参数的列表。 在表中,您可以看到在 IBM RPA Studio的脚本方式及其 Designer 方式等效标签中工作时的参数名称。
| 设计器方式标签 | 脚本方式名称 | 必需的 | 接受的变量类型 | 描述 |
|---|---|---|---|---|
| < | host |
Required |
Text |
SSH 服务器主机地址。 |
| 用户名 | username |
Required |
Text |
服务器访问的用户名。 |
| 密码 | password |
Optional |
Text |
服务器访问的密码。 |
| 端口 | port |
Optional |
Number |
连接到 SSH 服务器主机地址的端口号。 注:如果未输入端口,那么将使用缺省端口 (22)。
|
| 专用密钥 | keygen |
Required only when the pass-phrase is specified |
Text |
包含用于向 SSH 服务器进行认证的专用密钥对(认证密钥)的文件。 重要信息:请参阅命令限制。 |
| 口令 | passphrase |
Optional |
Text |
与在 Private Key 参数中指定的专用密钥文件关联的口令。 |
| Timeout | timeout |
Optional |
Time Span, Number, Text |
运行命令时的最长等待时间。 |
输出参数
| 设计器方式标签 | 脚本方式名称 | 接受的变量类型 | 描述 |
|---|---|---|---|
| SSH 连接 | 值 | SSH Session |
返回与 SSH 服务器建立的连接。 |
示例
SSH 登录命令使用名称,密码和具有专用密钥的文件来启动与 SSH 服务器的连接,然后通过隧道连接到目标服务器,并发送命令“ls”以从目标服务器的当前目录获取文件列表。
defVar --name sshConnection --type SSHSession
defVar --name sshTunnel --type SSHForwardedPort
defVar --name filesList --type String
// Initiate the connection to an SSH server.
startSSH --host "172.16.4.200" --username "User Name" --password password --port 22 --keygen "Private Key File" --passphrase "Pass Phrase" --timeout 00:00:05 sshConnection=value
// Create tunneling with the destination server.
openSSHTunnel --client ${sshConnection} --port 80 --boundport 8090 --destination "Local" --host "192.168.0.10" sshTunnel=value
// Sending the "ls" command to the SSH server for a list of file names from the current directory of the destination server.
executeSSH --client ${sshConnection} --command ls --timeout 00:00:05 filesList=value
// Connection to an SSH server to send commands to it is demonstrated.
//All host, port, and connection data is for example only, with both client services and SSH server installed.
// The user must enter valid data for a valid SSH connection!
限制
此命令不支持所有专用密钥格式和加密算法,使用其他类型可能会导致运行此命令时出现错误。
以下专用密钥受支持:
- OpenSSL PEM 和 ssh.com 格式的 RSA
- OpenSSL PEM 和 ssh.com 格式的 DSA
- OpenSSL PEM 格式的 ECDSA 256/384/521
- OpenSSH 密钥格式的 ED25519
以下加密算法受支持:
- DES-EDE3-CBC
- DES-EDE3-CFB
- DES-CBC
- ES-128-CBC
- AES-192-CBC
- AES-256-CBC