summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/clientloop.c
AgeCommit message (Collapse)Author
2021-12-19ssh client side of bindingDamien Miller
send session ID, hostkey, signature and a flag indicating whether the agent connection is being forwarded to ssh agent each time a connection is opened via a new "session-bind@openssh.com" agent extension. ok markus@
2021-11-18less confusing debug message; bz#3365Damien Miller
2021-08-29wrap at 80 columnsDamien Miller
2021-07-23Add a ForkAfterAuthentication ssh_config(5) counterpart to theDamien Miller
ssh(1) -f flag. Last part of GHPR231 from Volker Diels-Grabsch. ok dtucker
2021-07-23Add a StdinNull directive to ssh_config(5) that allows the configDamien Miller
file to do the same thing as -n does on the ssh(1) commandline. Patch from Volker Diels-Grabsch via GHPR231; ok dtucker
2021-07-16Explicitly check for and start time-based rekeying in the clientDamien Miller
and server mainloops. Previously the rekey timeout could expire but rekeying would not start until a packet was sent or received. This could cause us to spin in select() on the rekey timeout if the connection was quiet. ok markus@
2021-07-13add a SessionType directive to ssh_config, allowing the configurationDamien Miller
file to offer equivalent control to the -N (no session) and -s (subsystem) command-line flags. Part of GHPR#231 by Volker Diels-Grabsch with some minor tweaks; feedback and ok dtucker@
2021-07-05Fix a couple of whitespace things. Portable already has these so thisDarren Tucker
removes two diffs between the two.
2021-05-26fix SEGV in UpdateHostkeys debug() message, triggered when the updateDamien Miller
removed more host keys than remain present. Fix tested by reporter James Cook, via bugs@
2021-05-19restore blocking status on stdio fds before closeDamien Miller
ssh(1) needs to set file descriptors to non-blocking mode to operate but it was not restoring the original state on exit. This could cause problems with fds shared with other programs via the shell, e.g. > $ cat > test.sh << _EOF > #!/bin/sh > { > ssh -Fnone -oLogLevel=verbose ::1 hostname > cat /usr/share/dict/words > } | sleep 10 > _EOF > $ ./test.sh > Authenticated to ::1 ([::1]:22). > Transferred: sent 2352, received 2928 bytes, in 0.1 seconds > Bytes per second: sent 44338.9, received 55197.4 > cat: stdout: Resource temporarily unavailable This restores the blocking status for fds 0,1,2 (stdio) before ssh(1) abandons/closes them. This was reported as bz3280 and GHPR246; ok dtucker@
2021-05-04Don't pass NULL as a string in debugging as it does not work on someDarren Tucker
platforms in -portable. ok djm@
2021-05-03more debugging for UpdateHostKeys signature failuresDamien Miller
2021-04-30a little debugging in the main mux process for status confirmationDamien Miller
failures in multiplexed sessions
2021-03-19return non-zero exit status when killed by signal; bz#3281Damien Miller
ok dtucker@
2021-01-27make ssh->kex->session_id a sshbuf instead of u_char*/size_t andDamien Miller
use that instead of global variables containing copies of it. feedback/ok markus@
2021-01-27remove global variable used to stash compat flags and use theDamien Miller
purpose-built ssh->compat variable instead; feedback/ok markus@
2020-12-20load_hostkeys()/hostkeys_foreach() variants for FILE*Damien Miller
Add load_hostkeys_file() and hostkeys_foreach_file() that accept a FILE* argument instead of opening the file directly. Original load_hostkeys() and hostkeys_foreach() are implemented using these new interfaces. Add a u_int note field to the hostkey_entry and hostkey_foreach_line structs that is passed directly from the load_hostkeys() and hostkeys_foreach() call. This is a lightweight way to annotate results between different invocations of load_hostkeys(). ok markus@
2020-10-29UpdateHostkeys: fixed/better detection of host keys that exist underDamien Miller
other names and addresses; spotted by and debugged with lots of help from jca@
2020-10-18use the new variant log macros instead of prepending __func__ andDamien Miller
appending ssh_err(r) manually; ok markus@
2020-10-14make UpdateHostkeys still more conservative: refuse to proceed ifDamien Miller
one of the keys offered by the server is already in known_hosts under another name. This avoid collisions between address entries for different host aliases when CheckHostIP=yes Also, do not attempt to fix known_hosts with incomplete host/ip matches when there are no new or deprecated hostkeys.
2020-10-11UpdateHostkeys: check for keys under other namesDamien Miller
Stop UpdateHostkeys from automatically removing deprecated keys from known_hosts files if the same keys exist under a different name or address to the host that is being connected to. This avoids UpdateHostkeys from making known_hosts inconsistent in some cases. For example, multiple host aliases sharing address-based known_hosts on different lines, or hosts that resolves to multiple addresses. ok markus@
2020-10-11UpdateHostkeys: better CheckHostIP handlingDamien Miller
When preparing to update the known_hosts file, fully check both entries for both the host and the address (if CheckHostIP enabled) and ensure that, at the end of the operation, entries for both are recorded. Make sure this works with HashKnownHosts too, which requires maintaining a list of entry-types seen across the whole file for each key. ok markus@
2020-10-11UpdateHostkeys: better detect manual host entriesDamien Miller
Disable UpdateHostkeys if the known_hosts line has more than two entries in the pattern-list. ssh(1) only writes "host" or "host,ip" lines so anything else was added by a different tool or by a human. ok markus@
2020-10-08don't misdetect comma-separated hostkey names as wildcards;Damien Miller
spotted by naddy@
2020-10-07revert kex->flags cert hostkey downgrade back to a plain keyDamien Miller
(commitid VtF8vozGOF8DMKVg). We now do this a simpler way that needs less plumbing. ok markus@
2020-10-03disable UpdateHostkeys when a wildcard hostname pattern isDamien Miller
encountered or when a certificate host key is in use. feedback/ok markus@
2020-09-16Remove unused buf, last user was removed when switching to the sshbuf API.Darren Tucker
Patch from Sebastian Andrzej Siewior.
2020-07-03Only reset the serveralive check when we receive traffic from the serverDarren Tucker
and ignore traffic from a port forwarding client, preventing a client from keeping a connection alive when it should be terminated. Based on a patch from jxraynor at gmail.com via openssh-unix-dev and bz#2265, ok djm@
2020-04-24Remove leave_non_blocking() which is now dead code because nothing setsDarren Tucker
in_non_blocking_mode any more. Patch from michaael.meeks at collabora.com, ok djm@
2020-04-03make failures when establishing "Tunnel" forwarding terminate theDamien Miller
connection when ExitOnForwardFailure is enabled; bz3116; ok dtucker
2020-02-26change explicit_bzero();free() to freezero()Jonathan Gray
While freezero() returns early if the pointer is NULL the tests for NULL in callers are left to avoid warnings about passing an uninitialised size argument across a function boundry. ok deraadt@ djm@
2020-02-26Remove obsolete XXX comment. ok deraadt@Darren Tucker
2020-02-02Output (none) in debug in the case in the CheckHostIP=no case asDarren Tucker
suggested by markus@
2020-02-02Prevent possible null pointer deref of ip_str in debug.Darren Tucker
2020-01-30check the return value of ssh_packet_write_poll() and callDamien Miller
sshpkt_fatal() if it fails; avoid potential busy-loop under some circumstances. Based on patch by Mike Frysinger; ok dtucker@
2020-01-29markus suggests a simplification to previousDamien Miller
2020-01-29give more context to UpdateHostKeys messages, mentioning that theDamien Miller
changes are validated by the existing trusted host key. Prompted by espie@ feedback and ok markus@
2020-01-26for UpdateHostKeys, don't report errors for unsupported key types -Damien Miller
just ignore them. spotted by and ok dtucker@
2020-01-26downgrade error() for missing subsequent known_hosts files to debug()Damien Miller
as it was intended to be; spotted by dtucker@
2020-01-25allow UpdateKnownHosts=yes to function when multiple known_hosts filesDamien Miller
are in use. When updating host keys, ssh will now search subsequent known_hosts files, but will add new/changed host keys to the first specified file only. bz#2738 ok markus@
2020-01-23Replace all calls to signal(2) with a wrapper around sigaction(2).Darren Tucker
This wrapper blocks all other signals during the handler preventing races between handlers, and sets SA_RESTART which should reduce the potential for short read/write operations.
2020-01-23Remove unsupported algorithms from list of defaults at run time andDarren Tucker
remove ifdef and distinct settings for OPENSSL=no case. This will make things much simpler for -portable where the exact set of algos depends on the configuration of both OpenSSH and the libcrypto it's linked against (if any). ok djm@
2019-12-21Allow forwarding a different agent socket to the path specified byDamien Miller
$SSH_AUTH_SOCK, by extending the existing ForwardAgent option to accepting an explicit path or the name of an environment variable in addition to yes/no. Patch by Eric Chiang, manpage by me; ok markus@
2019-11-25Add new structure for signature optionsDamien Miller
This is populated during signature verification with additional fields that are present in and covered by the signature. At the moment, it is only used to record security key-specific options, especially the flags field. with and ok markus@
2019-11-13stdarg.h required more broadly; ok djmTheo de Raadt
2019-07-24When using a combination of a Yubikey+GnuPG+remote forwarding the gpg-agentRicardo Mestre
(and options ControlMaster+RemoteForward in ssh_config(5)) then the codepath taken will call mux_client_request_session -> mm_send_fd -> sendmsg(2). Since sendmsg(2) is not allowed in that codepath then pledge(2) kills the process. The solution is to add "sendfd" to pledge(2), which is not too bad considering a little bit later we reduce pledge(2) to only "stdio proc tty" in that codepath. Problem reported and diff provided by Timothy Brown <tbrown at freeshell.org> OK deraadt@
2019-06-28When system calls indicate an error they return -1, not some arbitraryTheo de Raadt
value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.
2019-06-26Remove unneeded unlink of xauthfile on error path. From Erik Sjölund viaDarren Tucker
github, ok djm@ deraadt@
2019-06-12Hostname->HostName cleanup; from lauri tirkkonenJason McIntyre
ok dtucker
2019-04-23Use the LogLevel typdef instead of int where appropriate. Patch fromDarren Tucker
Markus Schmidt via openssh-unix-dev, ok markus@