1 /* $OpenBSD: sshconnect.h,v 1.49 2025/03/01 06:11:26 dtucker Exp $ */ 2 3 /* 4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 struct sshkey; 28 29 typedef struct Sensitive Sensitive; 30 struct Sensitive { 31 struct sshkey **keys; 32 int nkeys; 33 }; 34 35 struct ssh_conn_info { 36 char *conn_hash_hex; 37 char *shorthost; 38 char *uidstr; 39 char *keyalias; 40 char *thishost; 41 char *host_arg; 42 char *portstr; 43 char *remhost; 44 char *remuser; 45 char *homedir; 46 char *locuser; 47 char *jmphost; 48 }; 49 50 struct addrinfo; 51 struct ssh; 52 struct hostkeys; 53 struct ssh_conn_info; 54 55 /* default argument for client percent expansions, minus remote user */ 56 #define DEFAULT_CLIENT_PERCENT_EXPAND_ARGS_NOUSER(conn_info) \ 57 "L", conn_info->shorthost, \ 58 "i", conn_info->uidstr, \ 59 "k", conn_info->keyalias, \ 60 "l", conn_info->thishost, \ 61 "n", conn_info->host_arg, \ 62 "p", conn_info->portstr, \ 63 "d", conn_info->homedir, \ 64 "h", conn_info->remhost, \ 65 "u", conn_info->locuser, \ 66 "j", conn_info->jmphost 67 68 /* same plus remote user and hash which has user as a component */ 69 #define DEFAULT_CLIENT_PERCENT_EXPAND_ARGS(conn_info) \ 70 DEFAULT_CLIENT_PERCENT_EXPAND_ARGS_NOUSER(conn_info), \ 71 "C", conn_info->conn_hash_hex, \ 72 "r", conn_info->remuser 73 74 int ssh_connect(struct ssh *, const char *, const char *, 75 struct addrinfo *, struct sockaddr_storage *, u_short, 76 int, int *, int); 77 void ssh_kill_proxy_command(void); 78 79 void ssh_login(struct ssh *, Sensitive *, const char *, 80 struct sockaddr *, u_short, struct passwd *, int, 81 const struct ssh_conn_info *); 82 83 int verify_host_key(char *, struct sockaddr *, struct sshkey *, 84 const struct ssh_conn_info *); 85 86 void get_hostfile_hostname_ipaddr(char *, struct sockaddr *, u_short, 87 char **, char **); 88 89 void ssh_kex2(struct ssh *ssh, char *, struct sockaddr *, u_short, 90 const struct ssh_conn_info *); 91 92 void ssh_userauth2(struct ssh *ssh, const char *, const char *, 93 char *, Sensitive *); 94 95 int ssh_local_cmd(const char *); 96 97 void maybe_add_key_to_agent(const char *, struct sshkey *, 98 const char *, const char *); 99 100 void load_hostkeys_command(struct hostkeys *, const char *, 101 const char *, const struct ssh_conn_info *, 102 const struct sshkey *, const char *); 103 104 int hostkey_accepted_by_hostkeyalgs(const struct sshkey *); 105