xref: /dflybsd-src/crypto/openssh/readconf.h (revision ba1276acd1c8c22d225b1bcf370a14c878644f44)
1*ba1276acSMatthew Dillon /* $OpenBSD: readconf.h,v 1.156 2024/03/04 02:16:11 djm Exp $ */
218de8d7fSPeter Avalos 
318de8d7fSPeter Avalos /*
418de8d7fSPeter Avalos  * Author: Tatu Ylonen <ylo@cs.hut.fi>
518de8d7fSPeter Avalos  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
618de8d7fSPeter Avalos  *                    All rights reserved
718de8d7fSPeter Avalos  * Functions for reading the configuration file.
818de8d7fSPeter Avalos  *
918de8d7fSPeter Avalos  * As far as I am concerned, the code I have written for this software
1018de8d7fSPeter Avalos  * can be used freely for any purpose.  Any derived versions of this
1118de8d7fSPeter Avalos  * software must be clearly marked as such, and if the derived work is
1218de8d7fSPeter Avalos  * incompatible with the protocol description in the RFC file, it must be
1318de8d7fSPeter Avalos  * called by a name other than "ssh" or "Secure Shell".
1418de8d7fSPeter Avalos  */
1518de8d7fSPeter Avalos 
1618de8d7fSPeter Avalos #ifndef READCONF_H
1718de8d7fSPeter Avalos #define READCONF_H
1818de8d7fSPeter Avalos 
1918de8d7fSPeter Avalos /* Data structure for representing option data. */
2018de8d7fSPeter Avalos 
2136e94dc5SPeter Avalos #define SSH_MAX_HOSTS_FILES	32
2236e94dc5SPeter Avalos #define MAX_CANON_DOMAINS	32
2336e94dc5SPeter Avalos #define PATH_MAX_SUN		(sizeof((struct sockaddr_un *)0)->sun_path)
2436e94dc5SPeter Avalos 
2536e94dc5SPeter Avalos struct allowed_cname {
2636e94dc5SPeter Avalos 	char *source_list;
2736e94dc5SPeter Avalos 	char *target_list;
2836e94dc5SPeter Avalos };
2918de8d7fSPeter Avalos 
3018de8d7fSPeter Avalos typedef struct {
31*ba1276acSMatthew Dillon 	char   *host_arg;	/* Host arg as specified on command line. */
3218de8d7fSPeter Avalos 	int     forward_agent;	/* Forward authentication agent. */
330cbfa66cSDaniel Fojt 	char   *forward_agent_sock_path; /* Optional path of the agent. */
3418de8d7fSPeter Avalos 	int     forward_x11;	/* Forward X11 display. */
35856ea928SPeter Avalos 	int     forward_x11_timeout;	/* Expiration for Cookies */
3618de8d7fSPeter Avalos 	int     forward_x11_trusted;	/* Trust Forward X11 display. */
3718de8d7fSPeter Avalos 	int     exit_on_forward_failure;	/* Exit if bind(2) fails for -L/-R */
3818de8d7fSPeter Avalos 	char   *xauth_location;	/* Location for xauth program */
3936e94dc5SPeter Avalos 	struct ForwardOptions fwd_opts;	/* forwarding options */
4018de8d7fSPeter Avalos 	int     pubkey_authentication;	/* Try ssh2 pubkey authentication. */
4118de8d7fSPeter Avalos 	int     hostbased_authentication;	/* ssh2's rhosts_rsa */
4218de8d7fSPeter Avalos 	int     gss_authentication;	/* Try GSS authentication */
4318de8d7fSPeter Avalos 	int     gss_deleg_creds;	/* Delegate GSS credentials */
4418de8d7fSPeter Avalos 	int     password_authentication;	/* Try password
4518de8d7fSPeter Avalos 						 * authentication. */
4618de8d7fSPeter Avalos 	int     kbd_interactive_authentication; /* Try keyboard-interactive auth. */
4718de8d7fSPeter Avalos 	char	*kbd_interactive_devices; /* Keyboard-interactive auth devices. */
4818de8d7fSPeter Avalos 	int     batch_mode;	/* Batch mode: do not ask for passwords. */
4918de8d7fSPeter Avalos 	int     check_host_ip;	/* Also keep track of keys for IP address */
5018de8d7fSPeter Avalos 	int     strict_host_key_checking;	/* Strict host key checking. */
5118de8d7fSPeter Avalos 	int     compression;	/* Compress packets in both directions. */
5218de8d7fSPeter Avalos 	int     tcp_keep_alive;	/* Set SO_KEEPALIVE. */
539f304aafSPeter Avalos 	int	ip_qos_interactive;	/* IP ToS/DSCP/class for interactive */
549f304aafSPeter Avalos 	int	ip_qos_bulk;		/* IP ToS/DSCP/class for bulk traffic */
55ce74bacaSMatthew Dillon 	SyslogFacility log_facility;	/* Facility for system logging. */
5618de8d7fSPeter Avalos 	LogLevel log_level;	/* Level for logging. */
5750a69bb5SSascha Wildner 	u_int	num_log_verbose;	/* Verbose log overrides */
5850a69bb5SSascha Wildner 	char   **log_verbose;
5918de8d7fSPeter Avalos 	int     port;		/* Port to connect. */
6018de8d7fSPeter Avalos 	int     address_family;
6118de8d7fSPeter Avalos 	int     connection_attempts;	/* Max attempts (seconds) before
6218de8d7fSPeter Avalos 					 * giving up */
6318de8d7fSPeter Avalos 	int     connection_timeout;	/* Max time (seconds) before
6418de8d7fSPeter Avalos 					 * aborting connection attempt */
6518de8d7fSPeter Avalos 	int     number_of_password_prompts;	/* Max number of password
6618de8d7fSPeter Avalos 						 * prompts. */
6718de8d7fSPeter Avalos 	char   *ciphers;	/* SSH2 ciphers in order of preference. */
6818de8d7fSPeter Avalos 	char   *macs;		/* SSH2 macs in order of preference. */
6918de8d7fSPeter Avalos 	char   *hostkeyalgorithms;	/* SSH2 server key types in order of preference. */
709f304aafSPeter Avalos 	char   *kex_algorithms;	/* SSH2 kex methods in order of preference. */
71664f4763Szrj 	char   *ca_sign_algorithms;	/* Allowed CA signature algorithms */
7218de8d7fSPeter Avalos 	char   *hostname;	/* Real host to connect. */
73*ba1276acSMatthew Dillon 	char   *tag;		/* Configuration tag name. */
7418de8d7fSPeter Avalos 	char   *host_key_alias;	/* hostname alias for .ssh/known_hosts */
7518de8d7fSPeter Avalos 	char   *proxy_command;	/* Proxy command for connecting the host. */
7618de8d7fSPeter Avalos 	char   *user;		/* User to log in as. */
7718de8d7fSPeter Avalos 	int     escape_char;	/* Escape character; -2 = none */
7818de8d7fSPeter Avalos 
791c188a7fSPeter Avalos 	u_int	num_system_hostfiles;	/* Paths for /etc/ssh/ssh_known_hosts */
801c188a7fSPeter Avalos 	char   *system_hostfiles[SSH_MAX_HOSTS_FILES];
811c188a7fSPeter Avalos 	u_int	num_user_hostfiles;	/* Path for $HOME/.ssh/known_hosts */
821c188a7fSPeter Avalos 	char   *user_hostfiles[SSH_MAX_HOSTS_FILES];
8318de8d7fSPeter Avalos 	char   *preferred_authentications;
8418de8d7fSPeter Avalos 	char   *bind_address;	/* local socket address for connection to sshd */
85664f4763Szrj 	char   *bind_interface;	/* local interface for bind address */
86856ea928SPeter Avalos 	char   *pkcs11_provider; /* PKCS#11 provider */
870cbfa66cSDaniel Fojt 	char   *sk_provider; /* Security key provider */
8818de8d7fSPeter Avalos 	int	verify_host_key_dns;	/* Verify host key using DNS */
8918de8d7fSPeter Avalos 
90*ba1276acSMatthew Dillon 	int     num_identity_files;	/* Number of files for identities. */
9118de8d7fSPeter Avalos 	char   *identity_files[SSH_MAX_IDENTITY_FILES];
9236e94dc5SPeter Avalos 	int    identity_file_userprovided[SSH_MAX_IDENTITY_FILES];
93e9778795SPeter Avalos 	struct sshkey *identity_keys[SSH_MAX_IDENTITY_FILES];
94e9778795SPeter Avalos 
95e9778795SPeter Avalos 	int	num_certificate_files; /* Number of extra certificates for ssh. */
96e9778795SPeter Avalos 	char	*certificate_files[SSH_MAX_CERTIFICATE_FILES];
97e9778795SPeter Avalos 	int	certificate_file_userprovided[SSH_MAX_CERTIFICATE_FILES];
98e9778795SPeter Avalos 	struct sshkey *certificates[SSH_MAX_CERTIFICATE_FILES];
99e9778795SPeter Avalos 
100e9778795SPeter Avalos 	int	add_keys_to_agent;
10150a69bb5SSascha Wildner 	int	add_keys_to_agent_lifespan;
102e9778795SPeter Avalos 	char   *identity_agent;		/* Optional path to ssh-agent socket */
10318de8d7fSPeter Avalos 
10418de8d7fSPeter Avalos 	/* Local TCP/IP forward requests. */
10518de8d7fSPeter Avalos 	int     num_local_forwards;
10636e94dc5SPeter Avalos 	struct Forward *local_forwards;
10718de8d7fSPeter Avalos 
10818de8d7fSPeter Avalos 	/* Remote TCP/IP forward requests. */
10918de8d7fSPeter Avalos 	int     num_remote_forwards;
11036e94dc5SPeter Avalos 	struct Forward *remote_forwards;
11118de8d7fSPeter Avalos 	int	clear_forwardings;
11218de8d7fSPeter Avalos 
11350a69bb5SSascha Wildner 	/* Restrict remote dynamic forwarding */
11450a69bb5SSascha Wildner 	char  **permitted_remote_opens;
11550a69bb5SSascha Wildner 	u_int	num_permitted_remote_opens;
11650a69bb5SSascha Wildner 
117e9778795SPeter Avalos 	/* stdio forwarding (-W) host and port */
118e9778795SPeter Avalos 	char   *stdio_forward_host;
119e9778795SPeter Avalos 	int	stdio_forward_port;
120e9778795SPeter Avalos 
12118de8d7fSPeter Avalos 	int	enable_ssh_keysign;
12218de8d7fSPeter Avalos 	int64_t rekey_limit;
12336e94dc5SPeter Avalos 	int	rekey_interval;
12418de8d7fSPeter Avalos 	int	no_host_authentication_for_localhost;
12518de8d7fSPeter Avalos 	int	identities_only;
12618de8d7fSPeter Avalos 	int	server_alive_interval;
12718de8d7fSPeter Avalos 	int	server_alive_count_max;
12818de8d7fSPeter Avalos 
129ee116499SAntonio Huete Jimenez 	u_int	num_send_env;
130664f4763Szrj 	char	**send_env;
131ee116499SAntonio Huete Jimenez 	u_int	num_setenv;
132664f4763Szrj 	char	**setenv;
13318de8d7fSPeter Avalos 
13418de8d7fSPeter Avalos 	char	*control_path;
13518de8d7fSPeter Avalos 	int	control_master;
136856ea928SPeter Avalos 	int     control_persist; /* ControlPersist flag */
137856ea928SPeter Avalos 	int     control_persist_timeout; /* ControlPersist timeout (seconds) */
13818de8d7fSPeter Avalos 
13918de8d7fSPeter Avalos 	int	hash_known_hosts;
14018de8d7fSPeter Avalos 
14118de8d7fSPeter Avalos 	int	tun_open;	/* tun(4) */
14218de8d7fSPeter Avalos 	int     tun_local;	/* force tun device (optional) */
14318de8d7fSPeter Avalos 	int     tun_remote;	/* force tun device (optional) */
14418de8d7fSPeter Avalos 
14518de8d7fSPeter Avalos 	char	*local_command;
14618de8d7fSPeter Avalos 	int	permit_local_command;
147ce74bacaSMatthew Dillon 	char	*remote_command;
14818de8d7fSPeter Avalos 	int	visual_host_key;
14918de8d7fSPeter Avalos 
1501c188a7fSPeter Avalos 	int	request_tty;
15150a69bb5SSascha Wildner 	int	session_type;
15250a69bb5SSascha Wildner 	int	stdin_null;
15350a69bb5SSascha Wildner 	int	fork_after_authentication;
15436e94dc5SPeter Avalos 
15536e94dc5SPeter Avalos 	int	proxy_use_fdpass;
15636e94dc5SPeter Avalos 
15736e94dc5SPeter Avalos 	int	num_canonical_domains;
158*ba1276acSMatthew Dillon 	char	**canonical_domains;
15936e94dc5SPeter Avalos 	int	canonicalize_hostname;
16036e94dc5SPeter Avalos 	int	canonicalize_max_dots;
16136e94dc5SPeter Avalos 	int	canonicalize_fallback_local;
16236e94dc5SPeter Avalos 	int	num_permitted_cnames;
163*ba1276acSMatthew Dillon 	struct allowed_cname *permitted_cnames;
16436e94dc5SPeter Avalos 
165e9778795SPeter Avalos 	char	*revoked_host_keys;
166e9778795SPeter Avalos 
167e9778795SPeter Avalos 	int	 fingerprint_hash;
168e9778795SPeter Avalos 
169e9778795SPeter Avalos 	int	 update_hostkeys; /* one of SSH_UPDATE_HOSTKEYS_* */
170e9778795SPeter Avalos 
17150a69bb5SSascha Wildner 	char   *hostbased_accepted_algos;
17250a69bb5SSascha Wildner 	char   *pubkey_accepted_algos;
173e9778795SPeter Avalos 
174e9778795SPeter Avalos 	char   *jump_user;
175e9778795SPeter Avalos 	char   *jump_host;
176e9778795SPeter Avalos 	int	jump_port;
177e9778795SPeter Avalos 	char   *jump_extra;
178e9778795SPeter Avalos 
17950a69bb5SSascha Wildner 	char   *known_hosts_command;
18050a69bb5SSascha Wildner 
181ee116499SAntonio Huete Jimenez 	int	required_rsa_size;	/* minimum size of RSA keys */
182*ba1276acSMatthew Dillon 	int	enable_escape_commandline;	/* ~C commandline */
183*ba1276acSMatthew Dillon 	int	obscure_keystroke_timing_interval;
184*ba1276acSMatthew Dillon 
185*ba1276acSMatthew Dillon 	char	**channel_timeouts;	/* inactivity timeout by channel type */
186*ba1276acSMatthew Dillon 	u_int	num_channel_timeouts;
187ee116499SAntonio Huete Jimenez 
18836e94dc5SPeter Avalos 	char	*ignored_unknown; /* Pattern list of unknown tokens to ignore */
18918de8d7fSPeter Avalos }       Options;
19018de8d7fSPeter Avalos 
191ee116499SAntonio Huete Jimenez #define SSH_PUBKEY_AUTH_NO	0x00
192ee116499SAntonio Huete Jimenez #define SSH_PUBKEY_AUTH_UNBOUND	0x01
193ee116499SAntonio Huete Jimenez #define SSH_PUBKEY_AUTH_HBOUND	0x02
194ee116499SAntonio Huete Jimenez #define SSH_PUBKEY_AUTH_ALL	0x03
195ee116499SAntonio Huete Jimenez 
19636e94dc5SPeter Avalos #define SSH_CANONICALISE_NO	0
19736e94dc5SPeter Avalos #define SSH_CANONICALISE_YES	1
19836e94dc5SPeter Avalos #define SSH_CANONICALISE_ALWAYS	2
19936e94dc5SPeter Avalos 
20018de8d7fSPeter Avalos #define SSHCTL_MASTER_NO	0
20118de8d7fSPeter Avalos #define SSHCTL_MASTER_YES	1
20218de8d7fSPeter Avalos #define SSHCTL_MASTER_AUTO	2
20318de8d7fSPeter Avalos #define SSHCTL_MASTER_ASK	3
20418de8d7fSPeter Avalos #define SSHCTL_MASTER_AUTO_ASK	4
20518de8d7fSPeter Avalos 
2061c188a7fSPeter Avalos #define REQUEST_TTY_AUTO	0
2071c188a7fSPeter Avalos #define REQUEST_TTY_NO		1
2081c188a7fSPeter Avalos #define REQUEST_TTY_YES		2
2091c188a7fSPeter Avalos #define REQUEST_TTY_FORCE	3
2101c188a7fSPeter Avalos 
21150a69bb5SSascha Wildner #define SESSION_TYPE_NONE	0
21250a69bb5SSascha Wildner #define SESSION_TYPE_SUBSYSTEM	1
21350a69bb5SSascha Wildner #define SESSION_TYPE_DEFAULT	2
21450a69bb5SSascha Wildner 
21536e94dc5SPeter Avalos #define SSHCONF_CHECKPERM	1  /* check permissions on config file */
21636e94dc5SPeter Avalos #define SSHCONF_USERCONF	2  /* user provided config file not system */
217664f4763Szrj #define SSHCONF_FINAL		4  /* Final pass over config, after canon. */
218e9778795SPeter Avalos #define SSHCONF_NEVERMATCH	8  /* Match/Host never matches; internal only */
219e9778795SPeter Avalos 
220e9778795SPeter Avalos #define SSH_UPDATE_HOSTKEYS_NO	0
221e9778795SPeter Avalos #define SSH_UPDATE_HOSTKEYS_YES	1
222e9778795SPeter Avalos #define SSH_UPDATE_HOSTKEYS_ASK	2
22336e94dc5SPeter Avalos 
224ce74bacaSMatthew Dillon #define SSH_STRICT_HOSTKEY_OFF	0
225ce74bacaSMatthew Dillon #define SSH_STRICT_HOSTKEY_NEW	1
226ce74bacaSMatthew Dillon #define SSH_STRICT_HOSTKEY_YES	2
227ce74bacaSMatthew Dillon #define SSH_STRICT_HOSTKEY_ASK	3
228ce74bacaSMatthew Dillon 
229*ba1276acSMatthew Dillon /* ObscureKeystrokes parameters */
230*ba1276acSMatthew Dillon #define SSH_KEYSTROKE_DEFAULT_INTERVAL_MS	20
231*ba1276acSMatthew Dillon #define SSH_KEYSTROKE_CHAFF_MIN_MS		1024
232*ba1276acSMatthew Dillon #define SSH_KEYSTROKE_CHAFF_RNG_MS		2048
233*ba1276acSMatthew Dillon 
2340cbfa66cSDaniel Fojt const char *kex_default_pk_alg(void);
2350cbfa66cSDaniel Fojt char	*ssh_connection_hash(const char *thishost, const char *host,
236*ba1276acSMatthew Dillon     const char *portstr, const char *user, const char *jump_host);
23718de8d7fSPeter Avalos void     initialize_options(Options *);
23850a69bb5SSascha Wildner int      fill_default_options(Options *);
23936e94dc5SPeter Avalos void	 fill_default_options_for_canonicalization(Options *);
24050a69bb5SSascha Wildner void	 free_options(Options *o);
241e9778795SPeter Avalos int	 process_config_line(Options *, struct passwd *, const char *,
242e9778795SPeter Avalos     const char *, char *, const char *, int, int *, int);
24336e94dc5SPeter Avalos int	 read_config_file(const char *, struct passwd *, const char *,
244664f4763Szrj     const char *, Options *, int, int *);
24536e94dc5SPeter Avalos int	 parse_forward(struct Forward *, const char *, int, int);
246e9778795SPeter Avalos int	 parse_jump(const char *, Options *, int);
247664f4763Szrj int	 parse_ssh_uri(const char *, char **, char **, int *);
24836e94dc5SPeter Avalos int	 default_ssh_port(void);
24936e94dc5SPeter Avalos int	 option_clear_or_none(const char *);
25050a69bb5SSascha Wildner int	 config_has_permitted_cnames(Options *);
251e9778795SPeter Avalos void	 dump_client_config(Options *o, const char *host);
25218de8d7fSPeter Avalos 
25336e94dc5SPeter Avalos void	 add_local_forward(Options *, const struct Forward *);
25436e94dc5SPeter Avalos void	 add_remote_forward(Options *, const struct Forward *);
25536e94dc5SPeter Avalos void	 add_identity_file(Options *, const char *, const char *, int);
256e9778795SPeter Avalos void	 add_certificate_file(Options *, const char *, int);
25718de8d7fSPeter Avalos 
25818de8d7fSPeter Avalos #endif				/* READCONF_H */
259