1*1c7715ddSchristos /* $NetBSD: sshconnect.h,v 1.18 2024/07/08 22:33:44 christos Exp $ */ 2*1c7715ddSchristos /* $OpenBSD: sshconnect.h,v 1.48 2024/04/30 02:10:49 djm Exp $ */ 3ca32bd8dSchristos 4ca32bd8dSchristos /* 5ca32bd8dSchristos * Copyright (c) 2000 Markus Friedl. All rights reserved. 6ca32bd8dSchristos * 7ca32bd8dSchristos * Redistribution and use in source and binary forms, with or without 8ca32bd8dSchristos * modification, are permitted provided that the following conditions 9ca32bd8dSchristos * are met: 10ca32bd8dSchristos * 1. Redistributions of source code must retain the above copyright 11ca32bd8dSchristos * notice, this list of conditions and the following disclaimer. 12ca32bd8dSchristos * 2. Redistributions in binary form must reproduce the above copyright 13ca32bd8dSchristos * notice, this list of conditions and the following disclaimer in the 14ca32bd8dSchristos * documentation and/or other materials provided with the distribution. 15ca32bd8dSchristos * 16ca32bd8dSchristos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17ca32bd8dSchristos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18ca32bd8dSchristos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19ca32bd8dSchristos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20ca32bd8dSchristos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21ca32bd8dSchristos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22ca32bd8dSchristos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23ca32bd8dSchristos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24ca32bd8dSchristos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25ca32bd8dSchristos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26ca32bd8dSchristos */ 27ca32bd8dSchristos 28*1c7715ddSchristos struct sshkey; 29*1c7715ddSchristos 30ca32bd8dSchristos typedef struct Sensitive Sensitive; 31ca32bd8dSchristos struct Sensitive { 327a183406Schristos struct sshkey **keys; 33ca32bd8dSchristos int nkeys; 34ca32bd8dSchristos }; 35ca32bd8dSchristos 3617418e98Schristos struct ssh_conn_info { 3717418e98Schristos char *conn_hash_hex; 3817418e98Schristos char *shorthost; 3917418e98Schristos char *uidstr; 4017418e98Schristos char *keyalias; 4117418e98Schristos char *thishost; 4217418e98Schristos char *host_arg; 4317418e98Schristos char *portstr; 4417418e98Schristos char *remhost; 4517418e98Schristos char *remuser; 4617418e98Schristos char *homedir; 4717418e98Schristos char *locuser; 48514b5d45Schristos char *jmphost; 4917418e98Schristos }; 5017418e98Schristos 518a4530f9Schristos struct addrinfo; 527a183406Schristos struct ssh; 5317418e98Schristos struct hostkeys; 5417418e98Schristos struct ssh_conn_info; 5517418e98Schristos 5617418e98Schristos /* default argument for client percent expansions */ 5717418e98Schristos #define DEFAULT_CLIENT_PERCENT_EXPAND_ARGS(conn_info) \ 5817418e98Schristos "C", conn_info->conn_hash_hex, \ 5917418e98Schristos "L", conn_info->shorthost, \ 6017418e98Schristos "i", conn_info->uidstr, \ 6117418e98Schristos "k", conn_info->keyalias, \ 6217418e98Schristos "l", conn_info->thishost, \ 6317418e98Schristos "n", conn_info->host_arg, \ 6417418e98Schristos "p", conn_info->portstr, \ 6517418e98Schristos "d", conn_info->homedir, \ 6617418e98Schristos "h", conn_info->remhost, \ 6717418e98Schristos "r", conn_info->remuser, \ 68514b5d45Schristos "u", conn_info->locuser, \ 69514b5d45Schristos "j", conn_info->jmphost 707a183406Schristos 71cd4ada6aSchristos int ssh_connect(struct ssh *, const char *, const char *, 72cd4ada6aSchristos struct addrinfo *, struct sockaddr_storage *, u_short, 7317418e98Schristos int, int *, int); 74185c8f97Schristos void ssh_kill_proxy_command(void); 75ca32bd8dSchristos 76aa36fcacSchristos void ssh_login(struct ssh *, Sensitive *, const char *, 7717418e98Schristos struct sockaddr *, u_short, struct passwd *, int, 7817418e98Schristos const struct ssh_conn_info *); 7947dc7704Schristos 8017418e98Schristos int verify_host_key(char *, struct sockaddr *, struct sshkey *, 8117418e98Schristos const struct ssh_conn_info *); 82ca32bd8dSchristos 83185c8f97Schristos void get_hostfile_hostname_ipaddr(char *, struct sockaddr *, u_short, 84185c8f97Schristos char **, char **); 85185c8f97Schristos 8617418e98Schristos void ssh_kex2(struct ssh *ssh, char *, struct sockaddr *, u_short, 8717418e98Schristos const struct ssh_conn_info *); 88ca32bd8dSchristos 89aa36fcacSchristos void ssh_userauth2(struct ssh *ssh, const char *, const char *, 90aa36fcacSchristos char *, Sensitive *); 91ca32bd8dSchristos 92ca32bd8dSchristos int ssh_local_cmd(const char *); 93ca32bd8dSchristos 94ed75d7a8Schristos void maybe_add_key_to_agent(const char *, struct sshkey *, 95ed75d7a8Schristos const char *, const char *); 9617418e98Schristos 9717418e98Schristos void load_hostkeys_command(struct hostkeys *, const char *, 9817418e98Schristos const char *, const struct ssh_conn_info *, 9917418e98Schristos const struct sshkey *, const char *); 100*1c7715ddSchristos 101*1c7715ddSchristos int hostkey_accepted_by_hostkeyalgs(const struct sshkey *); 102