The SSH Run Script Action is used to run scripts on an SSH server. The action can either run an entire script or a list of commands. All output is written to the build log as it is received from the host.
Note:
The action can not supplying user input to commands run on the host.
Host Name
The URL or IPv4 address of the SSH host to connect to. The host should be accessible from all agents able to run the build containing this action. If any connection issues are detected they will appear in the build log. Action will connect and represent itself as an xterm client. In addition it will use a channel to send commands so that it can easily detect when they have been completed. If a script is used in the action, SFTP will be used to upload the script to the host for execution. This guarantees that the script runs in the context of the host, and does not have to deal with any translation issues between the actions client and the server. Once run the script file will be removed from the SSH host.
Port
The port number that the SSH host will be listening on. Port 22 is the default port for SSH hosts.
Login Name
The name of the user under which all the commands will be run. The user will only be logged in for the lifetime of the action.
Password
The password for the supplied user. This password is stored as an encrypted value within the action, and once entered will not be able to be read by those editing the action. It will also not appear in any logs.
Run Option
Commands: The commands option allows for running of a sequence of commands in the action. The action will open a channel once connected and proceed to call each command in sequence waiting for the previous command to complete. Once all commands have been run, the channel and connection will be closed and the action will completed, returning the exitCode of the last run command.
Script: The script option allows for a script to be uploaded to the SSH host and run locally under the users account. This allows for commands to be run in the context of the SSH host and to avoid any translation issues between the actions client implementation and the host in question. The script is uploaded using SFTP, placing the file in the base directory of the logged in user. This requires the user to be able to write and execute files in their base directory. The script is then updated to be executable, and then executed from the users base directory. The action will then wait for the script to complete, and then sets the Exit Code Variable to the last error code of the script. Before completing the action will remove the script file, and then close the channel and connection.
Script File
The location of the script file to run. The script should be written as though it was run from the users login base directory and as the logged in user.
Script
The list of commands to run on the host.
Private Key
If the host uses SSH keys, the file containing the key can be supplied here. The action supports several private key formats: PKCS #8, OpenSSH/OpenSSL and PuTTY .ppk.
PKCS #8 keys
RFC 5208 (PKCS #8) defines a private key format informally known as PKCS #8 key format. It supports several encryption algorithms (3DES is used by default). To save keys using this format, specify SshPrivateKeyFormat.Pkcs8
when calling SshPrivateKey.Save
.
Sample of encrypted private key in Base64-encoded PKCS #8 format:
-----BEGIN ENCRYPTED PRIVATE KEY----- MIIBpjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQI5yNCu9T5SnsCAggA MBQGCCqGSIb3DQMHBAhJISTgOAxtYwSCAWDXK/a1lxHIbRZHud1tfRMR4ROqkmr4 kVGAnfqTyGptZUt3ZtBgrYlFAaZ1z0wxnhmhn3KIbqebI4w0cIL/3tmQ6eBD1Ad1 nSEjUxZCuzTkimXQ88wZLzIS9KHc8GhINiUu5rKWbyvWA13Ykc0w65Ot5MSw3cQc w1LEDJjTculyDcRQgiRfKH5376qTzukileeTrNebNq+wbhY1kEPAHojercB7d10E +QcbjJX1Tb1Zangom1qH9t/pepmV0Hn4EMzDs6DS2SWTffTddTY4dQzvksmLkP+J i8hkFIZwUkWpT9/k7MeklgtTiy0lR/Jj9CxAIQVxP8alLWbIqwCNRApleSmqtitt Z+NdsuNeTm3iUaPGYSw237tjLyVE6pr0EJqLv7VUClvJvBnH2qhQEtWYB9gvE1dS BioGu40pXVfjiLqhEKVVVEoHpI32oMkojhCGJs8Oow4bAxkzQFCtuWB1 -----END ENCRYPTED PRIVATE KEY-----
Sample of unencrypted private key in Base64-encoded PKCS #8 format:
-----BEGIN PRIVATE KEY----- MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEA0SC5BIYpanOv6wSm dHVVMRa+6iw/0aJpT9/LKcZ0XYQ43P9Vwn8c46MDvFJ+Uy41FwbxT+QpXBoLlp8D sJY/dQIDAQABAkAesoL2GwtxSNIF2YTli2OZ9RDJJv2nNAPpaZxU4YCrST1AXGPB tFm0LjYDDlGJ448syKRpdypAyCR2LidwrVRxAiEA+YU5Zv7bOwODCsmtQtIfBfhu 6SMBGMDijK7OYfTtjQsCIQDWjvly6b6doVMdNjqqTsnA8J1ShjSb8bFXkMels941 fwIhAL4Rr7I3PMRtXmrfSa325U7k+Yd59KHofCpyFiAkNLgVAiB8JdR+wnOSQAOY loVRgC9LXa6aTp9oUGxeD58F6VK9PwIhAIDhSxkrIatXw+dxelt8DY0bEdDbYzky r9nicR5wDy2W -----END PRIVATE KEY-----
PuTTY .ppk keys
This key format is used by PuTTY SSH client and utilities and by many PuTTY-derived third-party applications such as WinSCP or FileZilla Client. To save keys using this format, specify SshPrivateKeyFormat.Putty
when calling SshPrivateKey.Save
.
Sample of private key in PPKv2 format:
PuTTY-User-Key-File-2: ssh-rsa Encryption: aes256-cbc Comment: ssh-rsa-key-20130321 Public-Lines: 4 AAAAB3NzaC1yc2EAAAADAQABAAAAgQCdcXVZbOo81pToHiqMQgeosK80OXd8uxmC 514Mbp3VHL7eUshv9DlZ/Kc6vCpbkPLnkezLzy4QF9wQCiCem3+KFNbvgQ32R1vd ztguAIqrzzpoFjq2CPlyy7EuwmbI6k0xvcfAeU29MgnPk9/mkFFhW5084+9dwhz1 7BluYdJIEQ== Private-Lines: 8 FyXPkB7XlUE2y9WP7wGqmSwMo5RUdoqRbJGkHzMrpMlOOw5KA8QaxiOGixcDYuH4 8gTO4d8grFHcbRgZ7aJUycTdQxrPm8cey1EPUqLP9u3aCZYAqIMhUs5hsq7ujsq9 sK+jfTfY5N4ukYP2DumBreRPgKAE4W+gh/j//pnlJGJDEn32SOaRkiLoy1DB3VZ8 Nv8BPEAKV5ILKwef66KkN9FXPmEz3XQljEDcLNmzUTYypBQZqlYKze6V2cbZRZgi 7IYFV6ZGX8PMFnpSzwzoYfWXp9KQk1kmSqZNqBZ8IRt0KSSBAu5arKuZAI/MFQPU dwXyuZGt+4sP7pkE/1FuaMb8RENEyNcw/9mPKaJEcZuhtSqcwwZrXAULvca6BpdT hQwLIkovPa19ZA+miqfZvjo6UUnQyEfMe4biCesl11c/PWGf4BcgbVogQ+oXu7Gh iF1IoAoF/wqj0fiWX152wg== Private-MAC: bf45cca7382e573717004e328c08a9ac49f3ecf2
OpenSSH/OpenSSL (SSLeay) keys #
SSLeay key format is used by OpenSSH and OpenSSL suites for storing encrypted RSA and DSA keys. To save keys using this format, specify SshPrivateKeyFormat.OpenSsh
when calling SshPrivateKey.Save
.
A sample of a private key in OpenSSH format:
-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,393C44619C5B62FB g7l6jpFKUWqiU+7wvS+CRCpYygAchVIJTHmR9mTQwxQD6XUMMBfmLO+K6EgBGOt6 HxqTxQsAIAYtHQD370qQVC9aKF4Du2TkMiAlAiET6lyw7yEZeipkY46lJm74SvFJ xo3dLERKJBcDfNDoBJK/zjJN9I2zfUT2DgPodJwzWCfnk4g+/wWD6wNOSGM57XjR POQi4kJWI8zxX6v2REhybrfWwFxFaTpxMausotKa9R0hC+169DXGjnfXMPg6va6d MUVPHKhoNzUInRWA1FPF+Vt9z5X2jQMGf4AJN7W65QE7Q0Boao+aOERKDVTzP1Ff tRL6X0+BgXMjetqKGP0tJydiAVuP6vXEy1n8YrehUJSqNHJXT23o6kry/s7tMqzo ke96suSNyQKmPPjFq4MKe+v+/9mQzA4UUcVWgCi2dqZxPhNsAzBXTyIrnFcPykOY QPmdLMjpxeavbj8F5qZ8pREqDw+WpL8onI64udLFL3kjN5tCC9l3wHKDUJd6Q9y9 5gTKBnVcCRNvlKuLXbb7O5Z1hYKhpdqVJv8pLAhg2/BtTthseV8MjMnLEnbW6nSP SPLlev76vk/QK6PIR9hQrJGrzXJDvcYEpXJ2YBcgvEIbKR/eFAsPeM4Gin00M6Rj cDSO6p2ymxpiZ4AdDvgjkTkAx7ZXkxwrr7rRTOgyZZvuY/CpJbW4gs9a+zej5U77 RtWIHj+XZWvTQDPX5VcqDtE/C/bcsM9OQB019rkEcgDjKDtu9uWfDscSCxzMwfCi xHrpJwudVCF3M6WAvfuB0SLc6UCBALHbln2SksaC+7teUwJP9XD8hg== -----END RSA PRIVATE KEY-----
New OpenSSH keys #
New OpenSSH format is used by OpenSSH for storing encrypted or unencrypted EcDSA and Ed25519 keys, although it supports other key algorithms as well. To save keys using this format, specify SshPrivateKeyFormat.NewOpenSsh
when calling SshPrivateKey.Save
.
A sample of a private key in the new OpenSSH format:
-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jYmMAAAAGYmNyeXB0AAAAGAAAABAxBix87d JvVrEotmWsbAZwAAAAEAAAAAEAAAAzAAAAC3NzaC1lZDI1NTE5AAAAIPKKmhHgVw5SM8IH uo2XalsMHXvDwBxA7vL+TG/CACK9AAAAkNWU8rq/ToxIgS2BXVJNJI8SI8qHehGmUGEmMI A+w+bpKwhfWj/Z24DHXrtdPpeTbUT7KHODlBu+StJpN1vtW5kNSuMpE9fL+0GEIasIDsEY 9xD1sLtGAy0pMR6yzB3EW2OEZE8NoTCKJ0Xq18km8Uo1KG8naT2DeSEDzuHSP6NQWkJx5k BmP6jMW98HAsSIQA== -----END OPENSSH PRIVATE KEY-----
Passphrase
Exit Code Variable
Script timeout