SshConstants.java

  1. /*
  2.  * Copyright (C) 2018, 2021 Thomas Wolf <thomas.wolf@paranor.ch> and others
  3.  *
  4.  * This program and the accompanying materials are made available under the
  5.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  6.  * https://www.eclipse.org/org/documents/edl-v10.php.
  7.  *
  8.  * SPDX-License-Identifier: BSD-3-Clause
  9.  */

  10. package org.eclipse.jgit.transport;

  11. import org.eclipse.jgit.lib.Constants;

  12. /**
  13.  * Constants relating to ssh.
  14.  *
  15.  * @since 5.2
  16.  */
  17. @SuppressWarnings("nls")
  18. public final class SshConstants {

  19.     private SshConstants() {
  20.         // No instances, please.
  21.     }

  22.     /** IANA assigned port number for ssh. */
  23.     public static final int SSH_DEFAULT_PORT = 22;

  24.     /** URI scheme for ssh. */
  25.     public static final String SSH_SCHEME = "ssh";

  26.     /** URI scheme for sftp. */
  27.     public static final String SFTP_SCHEME = "sftp";

  28.     /** Default name for a ssh directory. */
  29.     public static final String SSH_DIR = ".ssh";

  30.     /** Name of the ssh config file. */
  31.     public static final String CONFIG = Constants.CONFIG;

  32.     /** Default name of the user "known hosts" file. */
  33.     public static final String KNOWN_HOSTS = "known_hosts";

  34.     // Config file keys

  35.     /**
  36.      * Property to control whether private keys are added to an SSH agent, if
  37.      * one is running, after having been loaded.
  38.      *
  39.      * @since 6.1
  40.      */
  41.     public static final String ADD_KEYS_TO_AGENT = "AddKeysToAgent";

  42.     /** Key in an ssh config file. */
  43.     public static final String BATCH_MODE = "BatchMode";

  44.     /** Key in an ssh config file. */
  45.     public static final String CANONICAL_DOMAINS = "CanonicalDomains";

  46.     /** Key in an ssh config file. */
  47.     public static final String CERTIFICATE_FILE = "CertificateFile";

  48.     /** Key in an ssh config file. */
  49.     public static final String CIPHERS = "Ciphers";

  50.     /** Key in an ssh config file. */
  51.     public static final String COMPRESSION = "Compression";

  52.     /** Key in an ssh config file. */
  53.     public static final String CONNECTION_ATTEMPTS = "ConnectionAttempts";

  54.     /**
  55.      * An OpenSSH time value for the connection timeout. In OpenSSH, this
  56.      * includes everything until the end of the initial key exchange; in JGit it
  57.      * covers only the underlying TCP connect.
  58.      *
  59.      * @since 6.1
  60.      */
  61.     public static final String CONNECT_TIMEOUT = "ConnectTimeout";

  62.     /** Key in an ssh config file. */
  63.     public static final String CONTROL_PATH = "ControlPath";

  64.     /** Key in an ssh config file. */
  65.     public static final String GLOBAL_KNOWN_HOSTS_FILE = "GlobalKnownHostsFile";

  66.     /**
  67.      * Key in an ssh config file.
  68.      *
  69.      * @since 5.5
  70.      */
  71.     public static final String HASH_KNOWN_HOSTS = "HashKnownHosts";

  72.     /** Key in an ssh config file. */
  73.     public static final String HOST = "Host";

  74.     /** Key in an ssh config file. */
  75.     public static final String HOST_KEY_ALGORITHMS = "HostKeyAlgorithms";

  76.     /** Key in an ssh config file. */
  77.     public static final String HOST_NAME = "HostName";

  78.     /** Key in an ssh config file. */
  79.     public static final String IDENTITIES_ONLY = "IdentitiesOnly";

  80.     /** Key in an ssh config file. */
  81.     public static final String IDENTITY_AGENT = "IdentityAgent";

  82.     /** Key in an ssh config file. */
  83.     public static final String IDENTITY_FILE = "IdentityFile";

  84.     /** Key in an ssh config file. */
  85.     public static final String KEX_ALGORITHMS = "KexAlgorithms";

  86.     /** Key in an ssh config file. */
  87.     public static final String LOCAL_COMMAND = "LocalCommand";

  88.     /** Key in an ssh config file. */
  89.     public static final String LOCAL_FORWARD = "LocalForward";

  90.     /** Key in an ssh config file. */
  91.     public static final String MACS = "MACs";

  92.     /** Key in an ssh config file. */
  93.     public static final String NUMBER_OF_PASSWORD_PROMPTS = "NumberOfPasswordPrompts";

  94.     /** Key in an ssh config file. */
  95.     public static final String PORT = "Port";

  96.     /** Key in an ssh config file. */
  97.     public static final String PREFERRED_AUTHENTICATIONS = "PreferredAuthentications";

  98.     /**
  99.      * Key in an ssh config file; defines signature algorithms for public key
  100.      * authentication as a comma-separated list.
  101.      *
  102.      * @since 5.11.1
  103.      */
  104.     public static final String PUBKEY_ACCEPTED_ALGORITHMS = "PubkeyAcceptedAlgorithms";

  105.     /** Key in an ssh config file. */
  106.     public static final String PROXY_COMMAND = "ProxyCommand";

  107.     /**
  108.      * Comma-separated list of jump hosts, defining a jump host chain <em>in
  109.      * reverse order</em>. Each jump host is a SSH URI or "[user@]host[:port]".
  110.      * <p>
  111.      * Reverse order means: to connect A->B->target, one can do in
  112.      * {@code ~/.ssh/config} either of:
  113.      * </p>
  114.      *
  115.      * <pre>
  116.      * Host target
  117.      *   ProxyJump B,A
  118.      * </pre>
  119.      * <p>
  120.      * <em>or</em>
  121.      * </p>
  122.      *
  123.      * <pre>
  124.      * Host target
  125.      *   ProxyJump B
  126.      *
  127.      * Host B
  128.      *   ProxyJump A
  129.      * </pre>
  130.      *
  131.      * @since 5.10
  132.      */
  133.     public static final String PROXY_JUMP = "ProxyJump";

  134.     /** Key in an ssh config file. */
  135.     public static final String REMOTE_COMMAND = "RemoteCommand";

  136.     /** Key in an ssh config file. */
  137.     public static final String REMOTE_FORWARD = "RemoteForward";

  138.     /**
  139.      * (Absolute) path to a middleware library the SSH agent shall use to load
  140.      * SK (U2F) keys.
  141.      *
  142.      * @since 6.1
  143.      */
  144.     public static final String SECURITY_KEY_PROVIDER = "SecurityKeyProvider";

  145.     /** Key in an ssh config file. */
  146.     public static final String SEND_ENV = "SendEnv";

  147.     /** Key in an ssh config file. */
  148.     public static final String STRICT_HOST_KEY_CHECKING = "StrictHostKeyChecking";

  149.     /** Key in an ssh config file. */
  150.     public static final String USER = "User";

  151.     /** Key in an ssh config file. */
  152.     public static final String USER_KNOWN_HOSTS_FILE = "UserKnownHostsFile";

  153.     // Values

  154.     /** Flag value. */
  155.     public static final String YES = "yes";

  156.     /** Flag value. */
  157.     public static final String ON = "on";

  158.     /** Flag value. */
  159.     public static final String TRUE = "true";

  160.     /** Flag value. */
  161.     public static final String NO = "no";

  162.     /** Flag value. */
  163.     public static final String OFF = "off";

  164.     /** Flag value. */
  165.     public static final String FALSE = "false";

  166.     /**
  167.      * Property value. Some keys accept a special 'none' value to override and
  168.      * clear a setting otherwise contributed by another host entry, for instance
  169.      * {@link #PROXY_COMMAND} or {@link #PROXY_JUMP}. Example:
  170.      *
  171.      * <pre>
  172.      * Host bastion.example.org
  173.      *   ProxyJump none
  174.      *
  175.      * Host *.example.org
  176.      *   ProxyJump bastion.example.org
  177.      * </pre>
  178.      * <p>
  179.      * OpenSSH supports this since OpenSSH 7.8.
  180.      * </p>
  181.      *
  182.      * @since 6.0
  183.      */
  184.     public static final String NONE = "none";

  185.     // Default identity file names

  186.     /** Name of the default RSA private identity file. */
  187.     public static final String ID_RSA = "id_rsa";

  188.     /** Name of the default DSA private identity file. */
  189.     public static final String ID_DSA = "id_dsa";

  190.     /** Name of the default ECDSA private identity file. */
  191.     public static final String ID_ECDSA = "id_ecdsa";

  192.     /** Name of the default ED25519 private identity file. */
  193.     public static final String ID_ED25519 = "id_ed25519";

  194.     /** All known default identity file names. */
  195.     public static final String[] DEFAULT_IDENTITIES = { //
  196.             ID_RSA, ID_DSA, ID_ECDSA, ID_ED25519
  197.     };

  198.     /**
  199.      * Name of the environment variable holding the Unix domain socket for
  200.      * communication with an SSH agent.
  201.      *
  202.      * @since 6.1
  203.      */
  204.     public static final String ENV_SSH_AUTH_SOCKET = "SSH_AUTH_SOCK";
  205. }