Ssh Man Page



(Redirected from SSH Keys)

This article or section needs expansion.

Reason: The intro and Background section ignore the server perspective. (Discuss in Talk:SSH keys#)
  1. SSHCONFIG(5) BSD File Formats Manual SSHCONFIG(5) NAME top sshconfig — OpenSSH client configuration file DESCRIPTION top ssh(1) obtains configuration data from the following sources in the following order: 1. Send a mail to man-pages@man7.org BSD February 28, 2021 BSD. HTML rendering created 2021-04-01.
  2. The ssh-keygen man page has a great explanation for each argument used. Basically, we're signing idecdsa.pub with ca. The certificate ID will be mfdutra and the only principal it has will be root. It's valid for one week and has the serial number 1.
  3. Ssh contains support for Virtual Private Network (VPN) tunnelling using the tun(4) network pseudo-device, allowing two networks to be joined securely. The sshdconfig(5) configuration option PermitTunnel controls whether the server supports this, and at what level (layer 2 or 3 traffic). The following example would connect client network 10.0.50.0/24 with remote network 10.0.99.0/24 using a.

SSH keys can serve as a means of identifying yourself to an SSH server using public-key cryptography and challenge-response authentication. The major advantage of key-based authentication is that in contrast to password authentication it is not prone to brute-force attacks and you do not expose valid credentials, if the server has been compromised.[1]

SSHORIGINALCOMMAND This will be the original command line of given by protocol if forced command is run. It can be used to fetch arguments etc from the other end. SSHTTY This is set to the name of the tty (path to the device) associated with the current shell or command. If the current session has no tty, this variable is not set. Ssh(1), ssh-add(1), ssh-agent(1), moduli(5), sshd(8) The Secure Shell (SSH) Public Key File Format, RFC 4716, 2006. AUTHORS OpenSSH is a derivative of the original and free ssh 1.2.12 release by Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo de Raadt and Dug Song removed many bugs, re-added newer features and created.

Furthermore SSH key authentication can be more convenient than the more traditional password authentication. When used with a program known as an SSH agent, SSH keys can allow you to connect to a server, or multiple servers, without having to remember or enter your password for each system.

Key-based authentication is not without its drawbacks and may not be appropriate for all environments, but in many circumstances it can offer some strong advantages. A general understanding of how SSH keys work will help you decide how and when to use them to meet your needs.

This article assumes you already have a basic understanding of the Secure Shell protocol and have installed the openssh package.

Background

SSH keys are always generated in pairs with one known as the private key and the other as the public key. The private key is known only to you and it should be safely guarded. By contrast, the public key can be shared freely with any SSH server to which you wish to connect.

If an SSH server has your public key on file and sees you requesting a connection, it uses your public key to construct and send you a challenge. This challenge is an encrypted message and it must be met with the appropriate response before the server will grant you access. What makes this coded message particularly secure is that it can only be understood by the private key holder. While the public key can be used to encrypt the message, it cannot be used to decrypt that very same message. Only you, the holder of the private key, will be able to correctly understand the challenge and produce the proper response.

This challenge-response phase happens behind the scenes and is invisible to the user. As long as you hold the private key, which is typically stored in the ~/.ssh/ directory, your SSH client should be able to reply with the appropriate response to the server.

A private key is a guarded secret and as such it is advisable to store it on disk in an encrypted form. When the encrypted private key is required, a passphrase must first be entered in order to decrypt it. While this might superficially appear as though you are providing a login password to the SSH server, the passphrase is only used to decrypt the private key on the local system. The passphrase is not transmitted over the network.

Generating an SSH key pair

An SSH key pair can be generated by running the ssh-keygen command, defaulting to 3072-bit RSA (and SHA256) which the ssh-keygen(1) man page says is 'generally considered sufficient' and should be compatible with virtually all clients and servers:

The randomart image was introduced in OpenSSH 5.1 as an easier means of visually identifying the key fingerprint.

Note: You can use the -a switch to specify the number of KDF rounds on the password encryption.

You can also add an optional comment field to the public key with the -C switch, to more easily identify it in places such as ~/.ssh/known_hosts, ~/.ssh/authorized_keys and ssh-add -L output. For example:

will add a comment saying which user created the key on which machine and when.

Choosing the authentication key type

OpenSSH supports several signing algorithms (for authentication keys) which can be divided in two groups depending on the mathematical properties they exploit:

  1. DSA and RSA, which rely on the practical difficulty of factoring the product of two large prime numbers,
  2. ECDSA and Ed25519, which rely on the elliptic curve discrete logarithm problem. (example)

Elliptic curve cryptography (ECC) algorithms are a more recent addition to public key cryptosystems. One of their main advantages is their ability to provide the same level of security with smaller keys, which makes for less computationally intensive operations (i.e. faster key creation, encryption and decryption) and reduced storage and transmission requirements.

OpenSSH 7.0 deprecated and disabled support for DSA keys due to discovered vulnerabilities, therefore the choice of cryptosystem lies within RSA or one of the two types of ECC.

#RSA keys will give you the greatest portability, while #Ed25519 will give you the best security but requires recent versions of client & server[2]. #ECDSA is likely more compatible than Ed25519 (though still less than RSA), but suspicions exist about its security (see below).

Note: These keys are used only to authenticate you; choosing stronger keys will not increase CPU load when transferring data over SSH.

RSA

ssh-keygen defaults to RSA therefore there is no need to specify it with the -t option. It provides the best compatibility of all algorithms but requires the key size to be larger to provide sufficient security.

Minimum key size is 1024 bits, default is 3072 (see ssh-keygen(1)) and maximum is 16384.

If you wish to generate a stronger RSA key pair (e.g. to guard against cutting-edge or unknown attacks and more sophisticated attackers), simply specify the -b option with a higher bit value than the default:

Be aware though that there are diminishing returns in using longer keys.[3][4] The GnuPG FAQ reads: 'If you need more security than RSA-2048 offers, the way to go would be to switch to elliptical curve cryptography — not to continue using RSA.'[5]

On the other hand, the latest iteration of the NSA Fact Sheet Suite B Cryptography suggests a minimum 3072-bit modulus for RSA while '[preparing] for the upcoming quantum resistant algorithm transition'.[6]

ECDSA

The Elliptic Curve Digital Signature Algorithm (ECDSA) was introduced as the preferred algorithm for authentication in OpenSSH 5.7. Some vendors also disable the required implementations due to potential patent issues.

There are two sorts of concerns with it:

  1. Political concerns, the trustworthiness of NIST-produced curves being questioned after revelations that the NSA willingly inserts backdoors into softwares, hardware components and published standards were made; well-known cryptographers haveexpresseddoubts about how the NIST curves were designed, and voluntary tainting has already beenproved in the past.
  2. Technical concerns, about the difficulty to properly implement the standard and the slowness and design flaws which reduce security in insufficiently precautious implementations.
Ssh

Both of those concerns are best summarized in libssh curve25519 introduction. Although the political concerns are still subject to debate, there is a clear consensus that #Ed25519 is technically superior and should therefore be preferred.

Ed25519

Ed25519 was introduced in OpenSSH 6.5 of January 2014: 'Ed25519 is an elliptic curve signature scheme that offers better security than ECDSA and DSA and good performance'. Its main strengths are its speed, its constant-time run time (and resistance against side-channel attacks), and its lack of nebulous hard-coded constants.[7] See also this blog post by a Mozilla developer on how it works.

It is already implemented in many applications and libraries and is the default key exchange algorithm (which is different from key signature) in OpenSSH.

Ed25519 key pairs can be generated with:

Ssh_config Man Page

There is no need to set the key size, as all Ed25519 keys are 256 bits.

Keep in mind that older SSH clients and servers may not support these keys.

Page

Choosing the key location and passphrase

Upon issuing the ssh-keygen command, you will be prompted for the desired name and location of your private key. By default, keys are stored in the ~/.ssh/ directory and named according to the type of encryption used. You are advised to accept the default name and location in order for later code examples in this article to work properly.

When prompted for a passphrase, choose something that will be hard to guess if you have the security of your private key in mind. A longer, more random password will generally be stronger and harder to crack should it fall into the wrong hands.

It is also possible to create your private key without a passphrase. While this can be convenient, you need to be aware of the associated risks. Without a passphrase, your private key will be stored on disk in an unencrypted form. Anyone who gains access to your private key file will then be able to assume your identity on any SSH server to which you connect using key-based authentication. Furthermore, without a passphrase, you must also trust the root user, as he can bypass file permissions and will be able to access your unencrypted private key file at any time.

Note: Previously, the private key password was encoded in an insecure way: only a single round of an MD5 hash. OpenSSH 6.5 and later support a new, more secure format to encode your private key. This format is the default since OpenSSH version 7.8. Ed25519 keys have always used the new encoding format. To upgrade to the new format, simply change the key's passphrase, as described in the next section.

Changing the private key's passphrase without changing the key

If the originally chosen SSH key passphrase is undesirable or must be changed, one can use the ssh-keygen command to change the passphrase without changing the actual key. This can also be used to change the password encoding format to the new standard.

Managing multiple keys

If you have multiple SSH identities, you can set different keys to be used for different hosts or remote users by using the Match and IdentityFile directives in your configuration:

See ssh_config(5) for full description of these options.

Storing SSH keys on hardware tokens

SSH keys can also be stored on a security token like a smart card or a USB token. This has the advantage that the private key is stored securely on the token instead of being stored on disk. When using a security token the sensitive private key is also never present in the RAM of the PC; the cryptographic operations are performed on the token itself. A cryptographic token has the additional advantage that it is not bound to a single computer; it can easily be removed from the computer and carried around to be used on other computers.

Examples are hardware tokens are described in:

  • YubiKey#SSH notes Native OpenSSH support for FIDO/U2F keys

Copying the public key to the remote server

This article or section needs expansion.

Reason: How to do this if you force public key authentication? (Discuss in Talk:SSH keys#)

Once you have generated a key pair, you will need to copy the public key to the remote server so that it will use SSH key authentication. The public key file shares the same name as the private key except that it is appended with a .pub extension. Note that the private key is not shared and remains on the local machine.

Simple method

Note: This method might fail if the remote server uses a non-sh shell such as tcsh as default and uses OpenSSH older than 6.6.1p1. See this bug report.

If your key file is ~/.ssh/id_rsa.pub you can simply enter the following command.

If your username differs on remote machine, be sure to prepend the username followed by @ to the server name.

If your public key filename is anything other than the default of ~/.ssh/id_rsa.pub you will get an error stating /usr/bin/ssh-copy-id: ERROR: No identities found. In this case, you must explicitly provide the location of the public key.

If the ssh server is listening on a port other than default of 22, be sure to include it within the host argument.

Manual method

By default, for OpenSSH, the public key needs to be concatenated with ~/.ssh/authorized_keys. Begin by copying the public key to the remote server.

The above example copies the public key (id_ecdsa.pub) to your home directory on the remote server via scp. Do not forget to include the : at the end of the server address. Also note that the name of your public key may differ from the example given.

On the remote server, you will need to create the ~/.ssh directory if it does not yet exist and append your public key to the authorized_keys file.

The last two commands remove the public key file from the server and set the permissions on the authorized_keys file such that it is only readable and writable by you, the owner.

SSH agents

If your private key is encrypted with a passphrase, this passphrase must be entered every time you attempt to connect to an SSH server using public-key authentication. Each individual invocation of ssh or scp will need the passphrase in order to decrypt your private key before authentication can proceed.

An SSH agent is a program which caches your decrypted private keys and provides them to SSH client programs on your behalf. In this arrangement, you must only provide your passphrase once, when adding your private key to the agent's cache. This facility can be of great convenience when making frequent SSH connections.

An agent is typically configured to run automatically upon login and persist for the duration of your login session. A variety of agents, front-ends, and configurations exist to achieve this effect. This section provides an overview of a number of different solutions which can be adapted to meet your specific needs.

ssh-agent

ssh-agent is the default agent included with OpenSSH. It can be used directly or serve as the back-end to a few of the front-end solutions mentioned later in this section. When ssh-agent is run, it forks to background and prints necessary environment variables. E.g.

To make use of these variables, run the command through the eval command.

Once ssh-agent is running, you will need to add your private key to its cache:

If your private key is encrypted, ssh-add will prompt you to enter your passphrase. Once your private key has been successfully added to the agent you will be able to make SSH connections without having to enter your passphrase.

Tip: To make all ssh clients, including git store keys in the agent on first use, add the configuration setting AddKeysToAgent yes to ~/.ssh/config. Other possible values are confirm, ask and no (default).

In order to start the agent automatically and make sure that only one ssh-agent process runs at a time, add the following to your ~/.bashrc:

This will run a ssh-agent process if there is not one already, and save the output thereof. If there is one running already, we retrieve the cached ssh-agent output and evaluate it which will set the necessary environment variables. The lifetime of the unlocked keys is set to 1 hour.

There also exist a number of front-ends to ssh-agent and alternative agents described later in this section which avoid this problem.

Start ssh-agent with systemd user

It is possible to use the systemd/User facilities to start the agent. Use this if you would like your ssh agent to run when you are logged in, regardless of whether x is running.

Then export the environment variableSSH_AUTH_SOCK='$XDG_RUNTIME_DIR/ssh-agent.socket' in your login shell initialization file, such as ~/.bash_profile.

Finally, enable or start the service with the --user flag.

Note: If you use GNOME, this environment variable is overridden by default. See GNOME/Keyring#Disable keyring daemon components.
Tip: When starting the agent via systemd as described above, it is possible to automatically enter the passphrase of your default key and add it to the agent. See systemd-user-pam-ssh for details.

ssh-agent as a wrapper program

An alternative way to start ssh-agent (with, say, each X session) is described in this ssh-agent tutorial by UC Berkeley Labs. A basic use case is if you normally begin X with the startx command, you can instead prefix it with ssh-agent like so:

And so you do not even need to think about it you can put an alias in your .bash_aliases file or equivalent:

Doing it this way avoids the problem of having extraneous ssh-agent instances floating around between login sessions. Exactly one instance will live and die with the entire X session.

Note: As an alternative to calling ssh-agent startx, you can add eval $(ssh-agent) to ~/.xinitrc.

See the below notes on using x11-ssh-askpass with ssh-add for an idea on how to immediately add your key to the agent.

GnuPG Agent

The gpg-agent has OpenSSH agent emulation. See GnuPG#SSH agent for necessary configuration.

Keychain

Keychain is a program designed to help you easily manage your SSH keys with minimal user interaction. It is implemented as a shell script which drives both ssh-agent and ssh-add. A notable feature of Keychain is that it can maintain a single ssh-agent process across multiple login sessions. This means that you only need to enter your passphrase once each time your local machine is booted.

Installation

Install the keychain package.

Configuration

Warning: As of 2015-09-26, the -Q, --quick option has the unexpected side-effect of making keychain switch to a newly-spawned ssh-agent upon relogin (at least on systems using GNOME), forcing you to re-add all the previously registered keys.
Man

Add a line similar to the following to your shell configuration file, e.g. if using Bash:

Note:~/.bashrc is used instead of the upstream suggested ~/.bash_profile because on Arch it is sourced by both login and non-login shells, making it suitable for textual and graphical environments alike. See Bash#Invocation for more information on the difference between those.

In the above example,

  • the --eval switch outputs lines to be evaluated by the opening eval command; this sets the necessary environment variables for an SSH client to be able to find your agent.
  • --quiet will limit output to warnings, errors, and user prompts.

Multiple keys can be specified on the command line, as shown in the example. By default keychain will look for key pairs in the ~/.ssh/ directory, but absolute path can be used for keys in non-standard location. You may also use the --confhost option to inform keychain to look in ~/.ssh/config for IdentityFile settings defined for particular hosts, and use these paths to locate keys.

See keychain --help or keychain(1) for details on setting keychain for other shells.

To test Keychain, simply open a new terminal emulator or log out and back in your session. It should prompt you for the passphrase of the specified private key(s) (if applicable), either using the program set in $SSH_ASKPASS or on the terminal.

Because Keychain reuses the same ssh-agent process on successive logins, you should not have to enter your passphrase the next time you log in or open a new terminal. You will only be prompted for your passphrase once each time the machine is rebooted.

Tips

  • keychain expects public key files to exist in the same directory as their private counterparts, with a .pub extension. If the private key is a symlink, the public key can be found alongside the symlink or in the same directory as the symlink target (this capability requires the readlink command to be available on the system).
  • to disable the graphical prompt and always enter your passphrase on the terminal, use the --nogui option. This allows to copy-paste long passphrases from a password manager for example.
  • if you do not want to be immediately prompted for unlocking the keys but rather wait until they are needed, use the --noask option.
Note: Keychain is able to manage GPG keys in the same fashion. By default it attempts to start ssh-agent only, but you can modify this behavior using the --agents option, e.g.--agents ssh,gpg. See keychain(1).

x11-ssh-askpass

The x11-ssh-askpass package provides a graphical dialog for entering your passhrase when running an X session. x11-ssh-askpass depends only on the libx11 and libxt libraries, and the appearance of x11-ssh-askpass is customizable. While it can be invoked by the ssh-add program, which will then load your decrypted keys into ssh-agent, the following instructions will, instead, configure x11-ssh-askpass to be invoked by the aforementioned Keychain script.

Install the keychain and x11-ssh-askpass packages.

Edit your ~/.xinitrc file to include the following lines, replacing the name and location of your private key if necessary. Be sure to place these commands before the line which invokes your window manager.

In the above example, the first line invokes keychain and passes the name and location of your private key. If this is not the first time keychain was invoked, the following two lines load the contents of $HOSTNAME-sh and $HOSTNAME-sh-gpg, if they exist. These files store the environment variables of the previous instance of keychain.

Calling x11-ssh-askpass with ssh-add

The ssh-add manual page specifies that, in addition to needing the DISPLAY variable defined, you also need SSH_ASKPASS set to the name of your askpass program (in this case x11-ssh-askpass). It bears keeping in mind that the default Arch Linux installation places the x11-ssh-askpass binary in /usr/lib/ssh/, which will not be in most people's PATH. This is a little annoying, not only when declaring the SSH_ASKPASS variable, but also when theming. You have to specify the full path everywhere. Both inconveniences can be solved simultaneously by symlinking:

Ssh Man Page

This is assuming that ~/bin is in your PATH. So now in your .xinitrc, before calling your window manager, one just needs to export the SSH_ASKPASS environment variable:

and your X resources will contain something like:

Doing it this way works well with the above method on using ssh-agent as a wrapper program. You start X with ssh-agent startx and then add ssh-add to your window manager's list of start-up programs.

Theming

The appearance of the x11-ssh-askpass dialog can be customized by setting its associated X resources. Some examples are the .ad files at https://github.com/sigmavirus24/x11-ssh-askpass. See x11-ssh-askpass(1) for full details.

Alternative passphrase dialogs

There are other passphrase dialog programs which can be used instead of x11-ssh-askpass. The following list provides some alternative solutions.

  • ksshaskpass uses the KDE Wallet.
  • openssh-askpass uses the Qt library.

pam_ssh

The pam_ssh project exists to provide a Pluggable Authentication Module (PAM) for SSH private keys. This module can provide single sign-on behavior for your SSH connections. On login, your SSH private key passphrase can be entered in place of, or in addition to, your traditional system password. Once you have been authenticated, the pam_ssh module spawns ssh-agent to store your decrypted private key for the duration of the session.

To enable single sign-on behavior at the tty login prompt, install the unofficial pam_sshAUR package.

Note: pam_ssh 2.0 now requires that all private keys used in the authentication process be located under ~/.ssh/login-keys.d/.

Create a symlink to your private key file and place it in ~/.ssh/login-keys.d/. Replace the id_rsa in the example below with the name of your own private key file.

Edit the /etc/pam.d/login configuration file to include the text highlighted in bold in the example below. The order in which these lines appear is significiant and can affect login behavior.

Warning: Misconfiguring PAM can leave the system in a state where all users become locked out. Before making any changes, you should have an understanding of how PAM configuration works as well as a backup means of accessing the PAM configuration files, such as an Arch Live CD, in case you become locked out and need to revert any changes. An IBM developerWorks article is available which explains PAM configuration in further detail.

In the above example, login authentication initially proceeds as it normally would, with the user being prompted to enter his user password. The additional auth authentication rule added to the end of the authentication stack then instructs the pam_ssh module to try to decrypt any private keys found in the ~/.ssh/login-keys.d directory. The try_first_pass option is passed to the pam_ssh module, instructing it to first try to decrypt any SSH private keys using the previously entered user password. If the user's private key passphrase and user password are the same, this should succeed and the user will not be prompted to enter the same password twice. In the case where the user's private key passphrase user password differ, the pam_ssh module will prompt the user to enter the SSH passphrase after the user password has been entered. The optional control value ensures that users without an SSH private key are still able to log in. In this way, the use of pam_ssh will be transparent to users without an SSH private key.

If you use another means of logging in, such as an X11 display manager like SLiM or XDM and you would like it to provide similar functionality, you must edit its associated PAM configuration file in a similar fashion. Packages providing support for PAM typically place a default configuration file in the /etc/pam.d/ directory.

Further details on how to use pam_ssh and a list of its options can be found in the pam_ssh(8) man page.

Using a different password to unlock the SSH key

If you want to unlock the SSH keys or not depending on whether you use your key's passphrase or the (different!) login password, you can modify /etc/pam.d/system-auth to

For an explanation, see [8].

Known issues with pam_ssh

Work on the pam_ssh project is infrequent and the documentation provided is sparse. You should be aware of some of its limitations which are not mentioned in the package itself.

  • Versions of pam_ssh prior to version 2.0 do not support SSH keys employing the newer option of ECDSA (elliptic curve) cryptography. If you are using earlier versions of pam_ssh you must use either RSA or DSA keys.
  • The ssh-agent process spawned by pam_ssh does not persist between user logins. If you like to keep a GNU Screen session active between logins you may notice when reattaching to your screen session that it can no longer communicate with ssh-agent. This is because the GNU Screen environment and those of its children will still reference the instance of ssh-agent which existed when GNU Screen was invoked but was subsequently killed in a previous logout. The Keychain front-end avoids this problem by keeping the ssh-agent process alive between logins.

pam_exec-ssh

As an alternative to pam_ssh you can use pam_exec-sshAUR. It is a shell script that uses pam_exec. Help for configuration can be found upstream.

GNOME Keyring

If you use the GNOME desktop, the GNOME Keyring tool can be used as an SSH agent. See the GNOME Keyring article for further details.

Store SSH keys with Kwallet

For instructions on how to use kwallet to store your SSH keys, see KDE Wallet#Using the KDE Wallet to store ssh key passphrases.

KeePass2 with KeeAgent plugin

KeeAgent is a plugin for KeePass that allows SSH keys stored in a KeePass database to be used for SSH authentication by other programs.

  • Supports both PuTTY and OpenSSH private key formats.
  • Works with native SSH agent on Linux/Mac and with PuTTY on Windows.

See KeePass#Plugin installation in KeePass or install the keepass-plugin-keeagent package.

This agent can be used directly, by matching KeeAgent socket: KeePass -> Tools -> Options -> KeeAgent -> Agent mode socket file -> %XDG_RUNTIME_DIR%/keeagent.socket-and environment variable:export SSH_AUTH_SOCK='$XDG_RUNTIME_DIR'/keeagent.socket'.

KeePassXC

The KeePassXC fork of KeePass supports being used as an SSH agent by default. It is also compatible with KeeAgent's database format.

Linux man page

Troubleshooting

Key ignored by the server

  • If it appears that the SSH server is ignoring your keys, ensure that you have the proper permissions set on all relevant files.
For the local machine:
For the remote machine:
For the remote machine, also check that the target user's home directory has the correct permissions (it must not be writable by the group and others):
  • If that does not solve the problem you may try temporarily setting StrictModes to no in /etc/ssh/sshd_config. If authentication with StrictModes off is successful, it is likely an issue with file permissions persists.
  • Make sure keys in ~/.ssh/authorized_keys are entered correctly and only use one single line.
  • Make sure the remote machine supports the type of keys you are using: some servers do not support ECDSA keys, try using RSA or DSA keys instead, see #Generating an SSH key pair.
  • You may want to use debug mode and monitor the output while connecting:
  • If you gave another name to your key, for example id_rsa_server, you need to connect with the -i option:

See also

  • OpenSSH key management: Part 1, Part 2, Part 3

Ssh-agent Man Page

Retrieved from 'https://wiki.archlinux.org/index.php?title=SSH_keys&oldid=662315'

The following plugin provides functionality available throughPipeline-compatible steps. Read more about how to integrate steps into yourPipeline in theStepssection of thePipeline Syntaxpage.

For a list of other such plugins, see thePipeline Steps Referencepage.

  • Publish Over SSH

Publish Over SSH

step([$class: 'BapSshPromotionPublisherPlugin']): Send build artifacts over SSH

Send files or execute commands over SSH as a build step during a promotion process.
  • publishers
      Array / List of Nested Object
    • configName

      Select an SSH configuration from the list configured in the global configuration of this Jenkins.

      The configuration defines the connection properties and base directory of the SSH server.

      • Type:String
    • verbose
      Select to enable an obscene amount of information to the Jenkins console - only really useful to help track down problems.
      • Type:boolean
    • transfers
        Array / List of Nested Object
      • sourceFiles

        Files to upload to a server.

        The string is a comma separated list of includes for an Ant fileset eg. '**/*.jar' (see Patterns in the Ant manual).
        The base directory for this fileset is the workspace.

        • Type:String
      • excludes

        Exclude files from the Transfer set.

        The string is a comma separated list of excludes for an Ant fileset eg. '**/*.log,**/*.tmp,.git/' (see Patterns in the Ant manual)

        • Type:String
      • remoteDirectory

        Optional destination folder.

        This folder will be below the one in the global configuration, if present.
        The folder will be created if does not exist.

        • Type:String
      • removePrefix

        First part of the file path that should not be created on the remote server.

        Directory structures are created relative to the base directory, which is usually the workspace.
        You normally do not want the full path to these files to be created on the server.
        For example if Source files were target/deployment/images/**/ then you may want Remove prefix to be target/deployment This would create the images folder under the remote directory, and not target/deployment
        Jenkins environment variables can be used in this path.

        If you use remove prefix, then ALL source file paths MUST start with the prefix.

        • Type:String
      • remoteDirectorySDF

        Select this to include the timestamp in the remote directory.

        The timestamp is the date of build. If this publisher is being used during a promotion, then the timestamp is that of the build that is being promoted.
        This setting turns the remote directory option into a java SimpleDateFormat.
        The SimpleDateFormat(SDF) uses letters to represent components of the date, like the month, year, or day of the week. Click here for more information about the date patterns.
        As the SDF reserves all of the letters [A-Z][a-z], any that you want to appear literally in the directory that is created will need to be quoted.

        Some examples follow - all examples are based on a build with a timestamp of 3:45 pm and 55 seconds on the 7th November 2010.

        Remote directoryDirectories created
        'qa-approved/'yyyyMMddHHmmssqa-approved/20101107154555
        'builds/'yyyy/MM/dd/'build-${BUILD_NUMBER}'builds/2010/11/07/build-456 (if the build was number 456)
        yyyy_MM/'build'-EEE-d-HHmmss2010_11/build-Sun-7-154555
        yyyy-MM-dd_HH-mm-ss2010-11-07_15-45-55
        • Type:boolean
      • flatten

        Only create files on the server, don't create directories (except for the remote directory, if present).

        All files that have been selected to transfer must have unique filenames. The publisher will stop and fail as soon as a duplicate filename is found when using the flatten option.

        • Type:boolean
      • cleanRemote
        • Type:boolean
      • noDefaultExcludes
        • Type:boolean
      • makeEmptyDirs

        The default behaviour of this plugin is to match files, and then create any directories required to preserve the paths to the files.
        Selecting this option will create any directories that match the Source files pattern, even if empty.

        • Type:boolean
      • patternSeparator

        The regular expression that is used to separate the Source files and Exclude files patterns.

        The Source files and Exclude files both accept multiple patterns that by default are split using

        which is how Ant, by default, handles multiple patterns in a single string.

        The above expression makes it difficult to reference files or directories that contain spaces. This option allows the expression to be set to something that will preserve the spaces in a pattern eg. a single comma.

        • Type:String
      • execCommand (optional)

        A command to execute on the remote server.

        This command will be executed on the remote server after any files are transferred.
        The SSH Transfer Set must include either a Source Files pattern, an Exec command, or both. If both are present, the files are transferred before the command is executed. If you want to Exec before the files are transferred, use 2 Transfer Sets and move the Exec command before the Transfer set that includes a Source files pattern.

        • Type:String
      • execTimeout (optional)

        Timeout in milliseconds for the Exec command.

        Set to zero to disable.

        • Type:int
      • usePty (optional)

        Exec the command in a pseudo tty.

        This will enable the execution of sudo commands that require a tty (and possibly help in other scenarios too.)
        From the sudoers(5) man page:

        • Type:boolean
      • useAgentForwarding (optional)

        Exec the command using Agent Forwarding.

        Allows a chain of ssh connections to forward key challenges back to the original agent, thus eliminating the need for using a password or public/private keys for these connections.

        From the ssh(1) man page:

        • Type:boolean
      • useSftpForExec (optional)

        Using SFTP protocol instead of SSH for Exec command.

        Supported commands: mkdir, ln, symlink, rm, rmdir, cd, get, ls

        • Type:boolean
    • useWorkspaceInPromotion

      Set the root directory for the Source files to the workspace.

      By default this plugin uses the artifacts directory (where archived artifacts are stored). This allows the artifacts from the build number that you are promoting to be sent somewhere else.

      If you run tasks that produce files in the workspace during the promotion and you want to publish them, then set this option.

      If you need to send files from both the workspace and the archive directory, then you need to add a second server, even if you want to send the files to the same place. This is due to the fact that the workspace is not necessarily on the same host as the archive directory.

      • Type:boolean
    • usePromotionTimestamp

      Use the build time of the promotion when the remote directory is a date format.

      By default this plugin uses the time of the original build (the one that is being promoted) when formatting the remote directory. Setting this option will mean that if you use the remote directory is a date format option, it will use the time that the promotion process runs, instead of the original build.

      • Type:boolean
    • sshRetry

      If publishing to this server or command execution fails, try again.

      Files that were successfully transferred will not be re-sent.
      If Exec command is configured, but fails in any way (including a non zero exit code), then it will be retried.

        Nested Object
      • retries
        The number of times to retry this server in the event of failure.
        • Type:int
      • retryDelay
        The time to wait, in milliseconds, before attempting another transfer.
        • Type:long
    • sshLabel

      Set the label for this Server instance - for use with Parameterized publishing.

      Expand the help for Parameterized publishing for more details.

        Nested Object
      • label

        Set the label for this Server instance - for use with Parameterized publishing.

        Expand the help for Parameterized publishing for more details.

        • Type:String
    • sshCredentials
      Set the credentials to use with this connection.

      If you want to use different credentials from those configured for this server, or if the credentials have not been specified for this server, then enable this option and set them here.

        Nested Object
      • username
        • Type:String
      • encryptedPassphrase
        The passphrase for the private key, or the password for password authentication if no Key or Path to key is configured.
        Leave blank if the key is not encrypted.
        • Type:String
      • key

        The private key.

        Paste the private key here, or provide the path to the file containing the key in Path to key.

        • Type:String
      • keyPath

        The path to the private key.

        Either supply the path to the file containing the key, or paste the key into the Key box.
        The Path to key can be absolute, or relative to $JENKINS_HOME

        • Type:String
  • continueOnError
    • Type:boolean
  • failOnError
    • Type:boolean
  • alwaysPublishFromMaster
    • Type:boolean
  • masterNodeName
    • Type:String
  • paramPublish
      Nested Object
    • parameterName
      The name of the parameter or environment variable that will contain the expression for matching the labels.
      • Type:String

sshPublisher: Send build artifacts over SSH

Openssh Man Page

  • alwaysPublishFromMaster (optional)

    Select to publish from the Jenkins master.

    The default is to publish from the server that holds the files to transfer (workspace on the agent, or artifacts directory on the master).
    Enabling this option could help dealing with strict network configurations and firewall rules.
    This option will cause the files to be transferred through the master before being sent to the remote server, this may increase network traffic, and could increase the build time.

    • Type:boolean
  • continueOnError (optional)
    Select to continue publishing to the other servers after a problem with a previous server.
    • Type:boolean
  • failOnError (optional)
    Select to mark the build as a failure if there is a problem publishing to a server. The default is to mark the build as unstable.
    • Type:boolean
  • masterNodeName (optional)

    Set the NODE_NAME for the master Jenkins.

    Set this option to give a value to the NODE_NAME environment variable when the value is missing (the Jenkins master).
    This is useful if you use the NODE_NAME variable in the remote directory option and the build may occur on the master.

    • Type:String
  • paramPublish (optional)
      Nested Object
    • parameterName
      The name of the parameter or environment variable that will contain the expression for matching the labels.
      • Type:String
  • publishers (optional)
      Array / List of Nested Object
    • configName

      Select an SSH configuration from the list configured in the global configuration of this Jenkins.

      The configuration defines the connection properties and base directory of the SSH server.

      • Type:String
    • verbose
      Select to enable an obscene amount of information to the Jenkins console - only really useful to help track down problems.
      • Type:boolean
    • transfers
        Array / List of Nested Object
      • sourceFiles

        Files to upload to a server.

        The string is a comma separated list of includes for an Ant fileset eg. '**/*.jar' (see Patterns in the Ant manual).
        The base directory for this fileset is the workspace.

        • Type:String
      • excludes

        Exclude files from the Transfer set.

        The string is a comma separated list of excludes for an Ant fileset eg. '**/*.log,**/*.tmp,.git/' (see Patterns in the Ant manual)

        • Type:String
      • remoteDirectory

        Optional destination folder.

        This folder will be below the one in the global configuration, if present.
        The folder will be created if does not exist.

        • Type:String
      • removePrefix

        First part of the file path that should not be created on the remote server.

        Directory structures are created relative to the base directory, which is usually the workspace.
        You normally do not want the full path to these files to be created on the server.
        For example if Source files were target/deployment/images/**/ then you may want Remove prefix to be target/deployment This would create the images folder under the remote directory, and not target/deployment
        Jenkins environment variables can be used in this path.

        If you use remove prefix, then ALL source file paths MUST start with the prefix.

        • Type:String
      • remoteDirectorySDF

        Select this to include the timestamp in the remote directory.

        The timestamp is the date of build. If this publisher is being used during a promotion, then the timestamp is that of the build that is being promoted.
        This setting turns the remote directory option into a java SimpleDateFormat.
        The SimpleDateFormat(SDF) uses letters to represent components of the date, like the month, year, or day of the week. Click here for more information about the date patterns.
        As the SDF reserves all of the letters [A-Z][a-z], any that you want to appear literally in the directory that is created will need to be quoted.

        Some examples follow - all examples are based on a build with a timestamp of 3:45 pm and 55 seconds on the 7th November 2010.

        Remote directoryDirectories created
        'qa-approved/'yyyyMMddHHmmssqa-approved/20101107154555
        'builds/'yyyy/MM/dd/'build-${BUILD_NUMBER}'builds/2010/11/07/build-456 (if the build was number 456)
        yyyy_MM/'build'-EEE-d-HHmmss2010_11/build-Sun-7-154555
        yyyy-MM-dd_HH-mm-ss2010-11-07_15-45-55
        • Type:boolean
      • flatten

        Only create files on the server, don't create directories (except for the remote directory, if present).

        All files that have been selected to transfer must have unique filenames. The publisher will stop and fail as soon as a duplicate filename is found when using the flatten option.

        • Type:boolean
      • cleanRemote
        • Type:boolean
      • noDefaultExcludes
        • Type:boolean
      • makeEmptyDirs

        The default behaviour of this plugin is to match files, and then create any directories required to preserve the paths to the files.
        Selecting this option will create any directories that match the Source files pattern, even if empty.

        • Type:boolean
      • patternSeparator

        The regular expression that is used to separate the Source files and Exclude files patterns.

        The Source files and Exclude files both accept multiple patterns that by default are split using

        which is how Ant, by default, handles multiple patterns in a single string.

        The above expression makes it difficult to reference files or directories that contain spaces. This option allows the expression to be set to something that will preserve the spaces in a pattern eg. a single comma.

        • Type:String
      • execCommand (optional)

        A command to execute on the remote server.

        This command will be executed on the remote server after any files are transferred.
        The SSH Transfer Set must include either a Source Files pattern, an Exec command, or both. If both are present, the files are transferred before the command is executed. If you want to Exec before the files are transferred, use 2 Transfer Sets and move the Exec command before the Transfer set that includes a Source files pattern.

        • Type:String
      • execTimeout (optional)

        Timeout in milliseconds for the Exec command.

        Set to zero to disable.

        • Type:int
      • usePty (optional)

        Exec the command in a pseudo tty.

        This will enable the execution of sudo commands that require a tty (and possibly help in other scenarios too.)
        From the sudoers(5) man page:

        • Type:boolean
      • useAgentForwarding (optional)

        Exec the command using Agent Forwarding.

        Allows a chain of ssh connections to forward key challenges back to the original agent, thus eliminating the need for using a password or public/private keys for these connections.

        From the ssh(1) man page:

        • Type:boolean
      • useSftpForExec (optional)

        Using SFTP protocol instead of SSH for Exec command.

        Supported commands: mkdir, ln, symlink, rm, rmdir, cd, get, ls

        • Type:boolean
    • useWorkspaceInPromotion

      Set the root directory for the Source files to the workspace.

      By default this plugin uses the artifacts directory (where archived artifacts are stored). This allows the artifacts from the build number that you are promoting to be sent somewhere else.

      If you run tasks that produce files in the workspace during the promotion and you want to publish them, then set this option.

      If you need to send files from both the workspace and the archive directory, then you need to add a second server, even if you want to send the files to the same place. This is due to the fact that the workspace is not necessarily on the same host as the archive directory.

      • Type:boolean
    • usePromotionTimestamp

      Use the build time of the promotion when the remote directory is a date format.

      By default this plugin uses the time of the original build (the one that is being promoted) when formatting the remote directory. Setting this option will mean that if you use the remote directory is a date format option, it will use the time that the promotion process runs, instead of the original build.

      • Type:boolean
    • sshRetry

      If publishing to this server or command execution fails, try again.

      Files that were successfully transferred will not be re-sent.
      If Exec command is configured, but fails in any way (including a non zero exit code), then it will be retried.

        Nested Object
      • retries
        The number of times to retry this server in the event of failure.
        • Type:int
      • retryDelay
        The time to wait, in milliseconds, before attempting another transfer.
        • Type:long
    • sshLabel

      Set the label for this Server instance - for use with Parameterized publishing.

      Expand the help for Parameterized publishing for more details.

        Nested Object
      • label

        Set the label for this Server instance - for use with Parameterized publishing.

        Expand the help for Parameterized publishing for more details.

        • Type:String
    • sshCredentials
      Set the credentials to use with this connection.

      If you want to use different credentials from those configured for this server, or if the credentials have not been specified for this server, then enable this option and set them here.

        Nested Object
      • username
        • Type:String
      • encryptedPassphrase
        The passphrase for the private key, or the password for password authentication if no Key or Path to key is configured.
        Leave blank if the key is not encrypted.
        • Type:String
      • key

        The private key.

        Paste the private key here, or provide the path to the file containing the key in Path to key.

        • Type:String
      • keyPath

        The path to the private key.

        Either supply the path to the file containing the key, or paste the key into the Key box.
        The Path to key can be absolute, or relative to $JENKINS_HOME

        • Type:String

Please submit your feedback about this page through thisquick form.

Man Sshd

Alternatively, if you don't wish to complete the quick form, you can simplyindicate if you found this page helpful?

See existing feedback here.