View Javadoc
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  
11  package org.eclipse.jgit.transport;
12  
13  import org.eclipse.jgit.lib.Constants;
14  
15  /**
16   * Constants relating to ssh.
17   *
18   * @since 5.2
19   */
20  @SuppressWarnings("nls")
21  public final class SshConstants {
22  
23  	private SshConstants() {
24  		// No instances, please.
25  	}
26  
27  	/** IANA assigned port number for ssh. */
28  	public static final int SSH_DEFAULT_PORT = 22;
29  
30  	/** URI scheme for ssh. */
31  	public static final String SSH_SCHEME = "ssh";
32  
33  	/** URI scheme for sftp. */
34  	public static final String SFTP_SCHEME = "sftp";
35  
36  	/** Default name for a ssh directory. */
37  	public static final String SSH_DIR = ".ssh";
38  
39  	/** Name of the ssh config file. */
40  	public static final String CONFIG = Constants.CONFIG;
41  
42  	/** Default name of the user "known hosts" file. */
43  	public static final String KNOWN_HOSTS = "known_hosts";
44  
45  	// Config file keys
46  
47  	/**
48  	 * Property to control whether private keys are added to an SSH agent, if
49  	 * one is running, after having been loaded.
50  	 *
51  	 * @since 6.1
52  	 */
53  	public static final String ADD_KEYS_TO_AGENT = "AddKeysToAgent";
54  
55  	/** Key in an ssh config file. */
56  	public static final String BATCH_MODE = "BatchMode";
57  
58  	/** Key in an ssh config file. */
59  	public static final String CANONICAL_DOMAINS = "CanonicalDomains";
60  
61  	/** Key in an ssh config file. */
62  	public static final String CERTIFICATE_FILE = "CertificateFile";
63  
64  	/** Key in an ssh config file. */
65  	public static final String CIPHERS = "Ciphers";
66  
67  	/** Key in an ssh config file. */
68  	public static final String COMPRESSION = "Compression";
69  
70  	/** Key in an ssh config file. */
71  	public static final String CONNECTION_ATTEMPTS = "ConnectionAttempts";
72  
73  	/**
74  	 * An OpenSSH time value for the connection timeout. In OpenSSH, this
75  	 * includes everything until the end of the initial key exchange; in JGit it
76  	 * covers only the underlying TCP connect.
77  	 *
78  	 * @since 6.1
79  	 */
80  	public static final String CONNECT_TIMEOUT = "ConnectTimeout";
81  
82  	/** Key in an ssh config file. */
83  	public static final String CONTROL_PATH = "ControlPath";
84  
85  	/** Key in an ssh config file. */
86  	public static final String GLOBAL_KNOWN_HOSTS_FILE = "GlobalKnownHostsFile";
87  
88  	/**
89  	 * Key in an ssh config file.
90  	 *
91  	 * @since 5.5
92  	 */
93  	public static final String HASH_KNOWN_HOSTS = "HashKnownHosts";
94  
95  	/** Key in an ssh config file. */
96  	public static final String HOST = "Host";
97  
98  	/** Key in an ssh config file. */
99  	public static final String HOST_KEY_ALGORITHMS = "HostKeyAlgorithms";
100 
101 	/** Key in an ssh config file. */
102 	public static final String HOST_NAME = "HostName";
103 
104 	/** Key in an ssh config file. */
105 	public static final String IDENTITIES_ONLY = "IdentitiesOnly";
106 
107 	/** Key in an ssh config file. */
108 	public static final String IDENTITY_AGENT = "IdentityAgent";
109 
110 	/** Key in an ssh config file. */
111 	public static final String IDENTITY_FILE = "IdentityFile";
112 
113 	/** Key in an ssh config file. */
114 	public static final String KEX_ALGORITHMS = "KexAlgorithms";
115 
116 	/** Key in an ssh config file. */
117 	public static final String LOCAL_COMMAND = "LocalCommand";
118 
119 	/** Key in an ssh config file. */
120 	public static final String LOCAL_FORWARD = "LocalForward";
121 
122 	/** Key in an ssh config file. */
123 	public static final String MACS = "MACs";
124 
125 	/** Key in an ssh config file. */
126 	public static final String NUMBER_OF_PASSWORD_PROMPTS = "NumberOfPasswordPrompts";
127 
128 	/** Key in an ssh config file. */
129 	public static final String PORT = "Port";
130 
131 	/** Key in an ssh config file. */
132 	public static final String PREFERRED_AUTHENTICATIONS = "PreferredAuthentications";
133 
134 	/**
135 	 * Key in an ssh config file; defines signature algorithms for public key
136 	 * authentication as a comma-separated list.
137 	 *
138 	 * @since 5.11.1
139 	 */
140 	public static final String PUBKEY_ACCEPTED_ALGORITHMS = "PubkeyAcceptedAlgorithms";
141 
142 	/** Key in an ssh config file. */
143 	public static final String PROXY_COMMAND = "ProxyCommand";
144 
145 	/**
146 	 * Comma-separated list of jump hosts, defining a jump host chain <em>in
147 	 * reverse order</em>. Each jump host is a SSH URI or "[user@]host[:port]".
148 	 * <p>
149 	 * Reverse order means: to connect A->B->target, one can do in
150 	 * {@code ~/.ssh/config} either of:
151 	 * </p>
152 	 *
153 	 * <pre>
154 	 * Host target
155 	 *   ProxyJump B,A
156 	 * </pre>
157 	 * <p>
158 	 * <em>or</em>
159 	 * </p>
160 	 *
161 	 * <pre>
162 	 * Host target
163 	 *   ProxyJump B
164 	 *
165 	 * Host B
166 	 *   ProxyJump A
167 	 * </pre>
168 	 *
169 	 * @since 5.10
170 	 */
171 	public static final String PROXY_JUMP = "ProxyJump";
172 
173 	/** Key in an ssh config file. */
174 	public static final String REMOTE_COMMAND = "RemoteCommand";
175 
176 	/** Key in an ssh config file. */
177 	public static final String REMOTE_FORWARD = "RemoteForward";
178 
179 	/**
180 	 * (Absolute) path to a middleware library the SSH agent shall use to load
181 	 * SK (U2F) keys.
182 	 *
183 	 * @since 6.1
184 	 */
185 	public static final String SECURITY_KEY_PROVIDER = "SecurityKeyProvider";
186 
187 	/** Key in an ssh config file. */
188 	public static final String SEND_ENV = "SendEnv";
189 
190 	/** Key in an ssh config file. */
191 	public static final String STRICT_HOST_KEY_CHECKING = "StrictHostKeyChecking";
192 
193 	/** Key in an ssh config file. */
194 	public static final String USER = "User";
195 
196 	/** Key in an ssh config file. */
197 	public static final String USER_KNOWN_HOSTS_FILE = "UserKnownHostsFile";
198 
199 	// Values
200 
201 	/** Flag value. */
202 	public static final String YES = "yes";
203 
204 	/** Flag value. */
205 	public static final String ON = "on";
206 
207 	/** Flag value. */
208 	public static final String TRUE = "true";
209 
210 	/** Flag value. */
211 	public static final String NO = "no";
212 
213 	/** Flag value. */
214 	public static final String OFF = "off";
215 
216 	/** Flag value. */
217 	public static final String FALSE = "false";
218 
219 	/**
220 	 * Property value. Some keys accept a special 'none' value to override and
221 	 * clear a setting otherwise contributed by another host entry, for instance
222 	 * {@link #PROXY_COMMAND} or {@link #PROXY_JUMP}. Example:
223 	 *
224 	 * <pre>
225 	 * Host bastion.example.org
226 	 *   ProxyJump none
227 	 *
228 	 * Host *.example.org
229 	 *   ProxyJump bastion.example.org
230 	 * </pre>
231 	 * <p>
232 	 * OpenSSH supports this since OpenSSH 7.8.
233 	 * </p>
234 	 *
235 	 * @since 6.0
236 	 */
237 	public static final String NONE = "none";
238 
239 	// Default identity file names
240 
241 	/** Name of the default RSA private identity file. */
242 	public static final String ID_RSA = "id_rsa";
243 
244 	/** Name of the default DSA private identity file. */
245 	public static final String ID_DSA = "id_dsa";
246 
247 	/** Name of the default ECDSA private identity file. */
248 	public static final String ID_ECDSA = "id_ecdsa";
249 
250 	/** Name of the default ED25519 private identity file. */
251 	public static final String ID_ED25519 = "id_ed25519";
252 
253 	/** All known default identity file names. */
254 	public static final String[] DEFAULT_IDENTITIES = { //
255 			ID_RSA, ID_DSA, ID_ECDSA, ID_ED25519
256 	};
257 
258 	/**
259 	 * Name of the environment variable holding the Unix domain socket for
260 	 * communication with an SSH agent.
261 	 *
262 	 * @since 6.1
263 	 */
264 	public static final String ENV_SSH_AUTH_SOCKET = "SSH_AUTH_SOCK";
265 }