readconf.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /* $OpenBSD: readconf.h,v 1.134 2020/08/11 09:49:57 djm Exp $ */
  2. /*
  3. * Author: Tatu Ylonen <ylo@cs.hut.fi>
  4. * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
  5. * All rights reserved
  6. * Functions for reading the configuration file.
  7. *
  8. * As far as I am concerned, the code I have written for this software
  9. * can be used freely for any purpose. Any derived versions of this
  10. * software must be clearly marked as such, and if the derived work is
  11. * incompatible with the protocol description in the RFC file, it must be
  12. * called by a name other than "ssh" or "Secure Shell".
  13. */
  14. #ifndef READCONF_H
  15. #define READCONF_H
  16. /* Data structure for representing option data. */
  17. #define SSH_MAX_HOSTS_FILES 32
  18. #define MAX_CANON_DOMAINS 32
  19. #define PATH_MAX_SUN (sizeof((struct sockaddr_un *)0)->sun_path)
  20. struct allowed_cname {
  21. char *source_list;
  22. char *target_list;
  23. };
  24. typedef struct {
  25. int forward_agent; /* Forward authentication agent. */
  26. char *forward_agent_sock_path; /* Optional path of the agent. */
  27. int forward_x11; /* Forward X11 display. */
  28. int forward_x11_timeout; /* Expiration for Cookies */
  29. int forward_x11_trusted; /* Trust Forward X11 display. */
  30. int exit_on_forward_failure; /* Exit if bind(2) fails for -L/-R */
  31. char *xauth_location; /* Location for xauth program */
  32. struct ForwardOptions fwd_opts; /* forwarding options */
  33. int pubkey_authentication; /* Try ssh2 pubkey authentication. */
  34. int hostbased_authentication; /* ssh2's rhosts_rsa */
  35. int challenge_response_authentication;
  36. /* Try S/Key or TIS, authentication. */
  37. int gss_authentication; /* Try GSS authentication */
  38. int gss_deleg_creds; /* Delegate GSS credentials */
  39. int password_authentication; /* Try password
  40. * authentication. */
  41. int kbd_interactive_authentication; /* Try keyboard-interactive auth. */
  42. char *kbd_interactive_devices; /* Keyboard-interactive auth devices. */
  43. int batch_mode; /* Batch mode: do not ask for passwords. */
  44. int check_host_ip; /* Also keep track of keys for IP address */
  45. int strict_host_key_checking; /* Strict host key checking. */
  46. int compression; /* Compress packets in both directions. */
  47. int tcp_keep_alive; /* Set SO_KEEPALIVE. */
  48. int tcp_rcv_buf; /* user switch to set tcp recv buffer */
  49. int tcp_rcv_buf_poll; /* Option to poll recv buf every window transfer */
  50. int hpn_disabled; /* Switch to disable HPN buffer management */
  51. int hpn_buffer_size; /* User definable size for HPN buffer window */
  52. int ip_qos_interactive; /* IP ToS/DSCP/class for interactive */
  53. int ip_qos_bulk; /* IP ToS/DSCP/class for bulk traffic */
  54. SyslogFacility log_facility; /* Facility for system logging. */
  55. LogLevel log_level; /* Level for logging. */
  56. int port; /* Port to connect. */
  57. int address_family;
  58. int connection_attempts; /* Max attempts (seconds) before
  59. * giving up */
  60. int connection_timeout; /* Max time (seconds) before
  61. * aborting connection attempt */
  62. int number_of_password_prompts; /* Max number of password
  63. * prompts. */
  64. char *ciphers; /* SSH2 ciphers in order of preference. */
  65. char *macs; /* SSH2 macs in order of preference. */
  66. char *hostkeyalgorithms; /* SSH2 server key types in order of preference. */
  67. char *kex_algorithms; /* SSH2 kex methods in order of preference. */
  68. char *ca_sign_algorithms; /* Allowed CA signature algorithms */
  69. char *hostname; /* Real host to connect. */
  70. char *host_key_alias; /* hostname alias for .ssh/known_hosts */
  71. char *proxy_command; /* Proxy command for connecting the host. */
  72. char *user; /* User to log in as. */
  73. int escape_char; /* Escape character; -2 = none */
  74. u_int num_system_hostfiles; /* Paths for /etc/ssh/ssh_known_hosts */
  75. char *system_hostfiles[SSH_MAX_HOSTS_FILES];
  76. u_int num_user_hostfiles; /* Path for $HOME/.ssh/known_hosts */
  77. char *user_hostfiles[SSH_MAX_HOSTS_FILES];
  78. char *preferred_authentications;
  79. char *bind_address; /* local socket address for connection to sshd */
  80. char *bind_interface; /* local interface for bind address */
  81. char *pkcs11_provider; /* PKCS#11 provider */
  82. char *sk_provider; /* Security key provider */
  83. int verify_host_key_dns; /* Verify host key using DNS */
  84. int num_identity_files; /* Number of files for RSA/DSA identities. */
  85. char *identity_files[SSH_MAX_IDENTITY_FILES];
  86. int identity_file_userprovided[SSH_MAX_IDENTITY_FILES];
  87. struct sshkey *identity_keys[SSH_MAX_IDENTITY_FILES];
  88. int num_certificate_files; /* Number of extra certificates for ssh. */
  89. char *certificate_files[SSH_MAX_CERTIFICATE_FILES];
  90. int certificate_file_userprovided[SSH_MAX_CERTIFICATE_FILES];
  91. struct sshkey *certificates[SSH_MAX_CERTIFICATE_FILES];
  92. int add_keys_to_agent;
  93. int add_keys_to_agent_lifespan;
  94. char *identity_agent; /* Optional path to ssh-agent socket */
  95. /* Local TCP/IP forward requests. */
  96. int num_local_forwards;
  97. struct Forward *local_forwards;
  98. /* Remote TCP/IP forward requests. */
  99. int num_remote_forwards;
  100. struct Forward *remote_forwards;
  101. int clear_forwardings;
  102. /* Restrict remote dynamic forwarding */
  103. char **permitted_remote_opens;
  104. u_int num_permitted_remote_opens;
  105. /* stdio forwarding (-W) host and port */
  106. char *stdio_forward_host;
  107. int stdio_forward_port;
  108. int enable_ssh_keysign;
  109. int64_t rekey_limit;
  110. int none_switch; /* Use none cipher */
  111. int none_enabled; /* Allow none to be used */
  112. int nonemac_enabled; /* Allow none to be used */
  113. int disable_multithreaded; /*disable multithreaded aes-ctr*/
  114. int rekey_interval;
  115. int no_host_authentication_for_localhost;
  116. int identities_only;
  117. int server_alive_interval;
  118. int server_alive_count_max;
  119. int num_send_env;
  120. char **send_env;
  121. int num_setenv;
  122. char **setenv;
  123. char *control_path;
  124. int control_master;
  125. int control_persist; /* ControlPersist flag */
  126. int control_persist_timeout; /* ControlPersist timeout (seconds) */
  127. int hash_known_hosts;
  128. int tun_open; /* tun(4) */
  129. int tun_local; /* force tun device (optional) */
  130. int tun_remote; /* force tun device (optional) */
  131. char *local_command;
  132. int permit_local_command;
  133. char *remote_command;
  134. int visual_host_key;
  135. int request_tty;
  136. int no_shell;
  137. int stdin_null;
  138. int fork_after_authentication;
  139. int proxy_use_fdpass;
  140. int num_canonical_domains;
  141. char *canonical_domains[MAX_CANON_DOMAINS];
  142. int canonicalize_hostname;
  143. int canonicalize_max_dots;
  144. int canonicalize_fallback_local;
  145. int num_permitted_cnames;
  146. struct allowed_cname permitted_cnames[MAX_CANON_DOMAINS];
  147. char *revoked_host_keys;
  148. int fingerprint_hash;
  149. int update_hostkeys; /* one of SSH_UPDATE_HOSTKEYS_* */
  150. char *hostbased_accepted_algos;
  151. char *pubkey_accepted_algos;
  152. char *jump_user;
  153. char *jump_host;
  154. int jump_port;
  155. char *jump_extra;
  156. char *ignored_unknown; /* Pattern list of unknown tokens to ignore */
  157. } Options;
  158. #define SSH_CANONICALISE_NO 0
  159. #define SSH_CANONICALISE_YES 1
  160. #define SSH_CANONICALISE_ALWAYS 2
  161. #define SSHCTL_MASTER_NO 0
  162. #define SSHCTL_MASTER_YES 1
  163. #define SSHCTL_MASTER_AUTO 2
  164. #define SSHCTL_MASTER_ASK 3
  165. #define SSHCTL_MASTER_AUTO_ASK 4
  166. #define REQUEST_TTY_AUTO 0
  167. #define REQUEST_TTY_NO 1
  168. #define REQUEST_TTY_YES 2
  169. #define REQUEST_TTY_FORCE 3
  170. #define SSHCONF_CHECKPERM 1 /* check permissions on config file */
  171. #define SSHCONF_USERCONF 2 /* user provided config file not system */
  172. #define SSHCONF_FINAL 4 /* Final pass over config, after canon. */
  173. #define SSHCONF_NEVERMATCH 8 /* Match/Host never matches; internal only */
  174. #define SSH_UPDATE_HOSTKEYS_NO 0
  175. #define SSH_UPDATE_HOSTKEYS_YES 1
  176. #define SSH_UPDATE_HOSTKEYS_ASK 2
  177. #define SSH_STRICT_HOSTKEY_OFF 0
  178. #define SSH_STRICT_HOSTKEY_NEW 1
  179. #define SSH_STRICT_HOSTKEY_YES 2
  180. #define SSH_STRICT_HOSTKEY_ASK 3
  181. const char *kex_default_pk_alg(void);
  182. char *ssh_connection_hash(const char *thishost, const char *host,
  183. const char *portstr, const char *user);
  184. void initialize_options(Options *);
  185. int fill_default_options(Options *);
  186. void fill_default_options_for_canonicalization(Options *);
  187. void free_options(Options *o);
  188. int process_config_line(Options *, struct passwd *, const char *,
  189. const char *, char *, const char *, int, int *, int);
  190. int read_config_file(const char *, struct passwd *, const char *,
  191. const char *, Options *, int, int *);
  192. int parse_forward(struct Forward *, const char *, int, int);
  193. int parse_jump(const char *, Options *, int);
  194. int parse_ssh_uri(const char *, char **, char **, int *);
  195. int default_ssh_port(void);
  196. int option_clear_or_none(const char *);
  197. void dump_client_config(Options *o, const char *host);
  198. void add_local_forward(Options *, const struct Forward *);
  199. void add_remote_forward(Options *, const struct Forward *);
  200. void add_identity_file(Options *, const char *, const char *, int);
  201. void add_certificate_file(Options *, const char *, int);
  202. #endif /* READCONF_H */