summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/sshconnect.c
AgeCommit message (Collapse)Author
2023-03-10Explicitly ignore return from fcntl(... FD_CLOEXEC) here too.Darren Tucker
Coverity CID 291853.
2023-03-05Remove unused compat.h includes. We've previously removed a lotDarren Tucker
of the really old compatibility code, and with it went the need to include compat.h in most of the files that have it.
2023-01-13avoid printf("%s", NULL) if using ssh -oUserKnownHostsFile=noneDamien Miller
and a hostkey in one of the system known hosts file changes; ok dtucker@
2022-11-03replace recently-added valid_domain() check for hostnames going toDamien Miller
known_hosts with a more relaxed check for bad characters; previous commit broke address literals. Reported by/feedback from florian@
2022-10-24Be more paranoid with host/domain names coming from the resolver:Damien Miller
don't follow CNAMEs with invalid characters when canonicalising and never write a name with bad characters to a known_hosts file. reported by David Leadbeater, ok deraadt@
2022-08-26whitespaceDamien Miller
2022-06-03Add period at end of "not known by any other names" message. github PR#320Darren Tucker
from jschauma, ok djm@
2021-12-19ssh-add side of destination constraintsDamien Miller
Have ssh-add accept a list of "destination constraints" that allow restricting where keys may be used in conjunction with a ssh-agent/ssh that supports session ID/hostkey binding. Constraints are specified as either "[user@]host-pattern" or "host-pattern>[user@]host-pattern". The first form permits a key to be used to authenticate as the specified user to the specified host. The second form permits a key that has previously been permitted for use at a host to be available via a forwarded agent to an additional host. For example, constraining a key with "user1@host_a" and "host_a>host_b". Would permit authentication as "user1" at "host_a", and allow the key to be available on an agent forwarded to "host_a" only for authentication to "host_b". The key would not be visible on agent forwarded to other hosts or usable for authentication there. Internally, destination constraints use host keys to identify hosts. The host patterns are used to obtain lists of host keys for that destination that are communicated to the agent. The user/hostkeys are encoded using a new restrict-destination-v00@openssh.com key constraint. host keys are looked up in the default client user/system known_hosts files. It is possible to override this set on the command-line. feedback Jann Horn & markus@ ok markus@
2021-07-02Remove references to ChallengeResponseAuthentication in favour ofDarren Tucker
KbdInteractiveAuthentication. The former is what was in SSHv1, the latter is what is in SSHv2 (RFC4256) and they were treated as somewhat but not entirely equivalent. We retain the old name as deprecated alias so config files continue to work and a reference in the man page for people looking for it. Prompted by bz#3303 which pointed out the discrepancy between the two when used with Match. Man page help & ok jmc@, with & ok djm@
2021-06-25Use better language to refer to the user. From l1ving via githubDarren Tucker
PR#250, ok jmc@
2021-06-08Allow argv_split() to optionally terminate tokenisation when itDamien Miller
encounters an unquoted comment. Add some additional utility function for working with argument vectors, since we'll be switching to using them to parse ssh/sshd_config shortly. ok markus@ as part of a larger diff; tested in snaps
2021-04-03highly polished whitespace, mostly fixing spaces-for-tab and badDamien Miller
indentation on continuation lines. Prompted by GHPR#185
2021-03-03typo in other_hostkeys_message() display output, ok djmStuart Henderson
2021-01-26move check_host_cert() from sshconnect,c to sshkey.c and refactorDamien Miller
it to make it more generally usable and testable. ok markus@
2020-12-22add a ssh_config KnownHostsCommand that allows the client to obtainDamien Miller
known_hosts data from a command in addition to the usual files. The command accepts bunch of %-expansions, including details of the connection and the offered server host key. Note that the command may be invoked up to three times per connection (see the manpage for details). ok markus@
2020-12-20plumb ssh_conn_info through to sshconnect.c; feedback/ok markus@Damien Miller
2020-12-20allow UserKnownHostsFile=none; feedback and ok markus@Damien Miller
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-11-27Set the specified TOS/DSCP for interactive use prior to TCP connect.Damien Miller
The connection phase of the SSH session is time-sensitive (due to server side login grace periods) and is frequently interactive (e.g. entering passwords). The ultimate interactive/bulk TOS/DSCP will be set after authentication completes. ok dtucker@
2020-11-22when mentioning that the host key has changed, don't report the typeDamien Miller
because it is ambiguous as to whether it referred to the known or new host key. bz3216; ok dtucker@
2020-11-20Explicitly initialize all members of the find_by_key_ctx struct. InitializingDarren Tucker
a single member should be enough (the spec says the remainder should be initialized as per the static rules) but some GCCs warn on this which prevents us testing with -Werror on those. ok deraadt@ djm@
2020-11-12when prompting the user to accept a new hostkey, display any otherDamien Miller
host names/addresses already associated with the key. E.g. > The authenticity of host 'test (10.0.0.1)' can't be established. > ECDSA key fingerprint is SHA256:milU4MODXm8iJQI18wlsbPG7Yup+34fuNNmV08qDnax. > This host key is known by the following other names/addresses: > ~/.ssh/known_hosts:1: host.example.org,10.0.0.1 > ~/.ssh/known_hosts:2: [hashed name] > ~/.ssh/known_hosts:3: [hashed name] > ~/.ssh/known_hosts:4: host > ~/.ssh/known_hosts:5: [host]:2222 > Are you sure you want to continue connecting (yes/no/[fingerprint])? feedback and ok markus@
2020-10-18use the new variant log macros instead of prepending __func__ andDamien Miller
appending ssh_err(r) manually; ok markus@
2020-10-12Zap unused family parameter from ssh_connect_direct()kn
sshconnect.c r1.241 from 2013 made it unused; found while reading code. OK djm
2020-10-07Disable UpdateHostkeys when hostkey checking failsDamien Miller
If host key checking fails (i.e. a wrong host key is recorded for the server) and the user elects to continue (via StrictHostKeyChecking=no), then disable UpdateHostkeys for the session. reminded by Mark D. Baushke; ok markus@
2020-10-07don't UpdateHostkeys when the hostkey is verified by theDamien Miller
GlobalKnownHostsFile file, support only UserKnownHostsFile matches suggested by Mark D. Baushke; feedback and ok markus@
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-07simply disable UpdateHostkeys when a certificate successfullyDamien Miller
authenticated the host; simpler than the complicated plumbing via kex->flags we have now. ok markus@
2020-10-04when ordering host key algorithms in the client, consider the ECDSADamien Miller
key subtype; ok markus@
2020-10-03There are lots of place where we want to redirect stdin, stdoutDamien Miller
and/or stderr to /dev/null. Factor all these out to a single stdfd_devnull() function that allows selection of which of these to redirect. ok markus@
2020-10-03record when the host key checking code downgrades a certificate hostDamien Miller
key to a plain key. This occurs when the user connects to a host with a certificate host key but no corresponding CA key configured in known_hosts; feedback and ok markus@
2020-09-09For the hostkey confirmation message:Damien Miller
> Are you sure you want to continue connecting (yes/no/[fingerprint])? compare the fingerprint case sensitively; spotted Patrik Lundin ok dtucker
2020-08-11let ssh_config(5)'s AddKeysToAgent keyword accept a time limit forDamien Miller
keys in addition to its current flag options. Time-limited keys will automatically be removed from ssh-agent after their expiry time has passed; ok markus@
2020-07-17Add a '%k' TOKEN that expands to the effective HostKey of theDarren Tucker
destination. This allows, eg, keeping host keys in individual files using "UserKnownHostsFile ~/.ssh/known_hosts.d/%k". bz#1654, ok djm@, jmc@ (man page bits)
2020-03-13use sshpkt_fatal() for kex_exchange_identification() errors.Damien Miller
This ensures that the logged errors are consistent with other transport- layer errors and that the relevant IP addresses are logged. bz3129 ok dtucker@
2020-01-25when AddKeysToAgent=yes is set and the key contains no comment,Damien Miller
add the key to the agent with the key's path as the comment. bz2564
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-22Ignore whitespace when checking explict fingerprint. When confirming a hostDarren Tucker
key using the fingerprint itself, ignore leading and trailing whitespace. ok deraadt@ djm@
2020-01-11revise the fix for reversed arguments on expand_proxy_command()Christian Weisgerber
Always put 'host' before 'host_arg' for consistency. ok markus@ djm@
2020-01-09fix reversed arguments on expand_proxy_command(); spotted byDamien Miller
anton@
2019-11-13stdarg.h required more broadly; ok djmTheo de Raadt
2019-11-12enable ed25519 support; ok djmMarkus Friedl
2019-10-31ssh AddKeysToAgent support for U2F/FIDO keysDamien Miller
feedback & ok markus@
2019-10-31add new agent key constraint for U2F/FIDO providerDamien Miller
feedback & ok markus@
2019-09-13whitespaceDamien Miller
2019-09-13allow %n to be expanded in ProxyCommand stringsDamien Miller
From Zachary Harmany via github.com/openssh/openssh-portable/pull/118 ok dtucker@
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-21Add protection for private keys at rest in RAM against speculationDamien Miller
and memory sidechannel attacks like Spectre, Meltdown, Rowhammer and Rambleed. This change encrypts private keys when they are not in use with a symmetic key that is derived from a relatively large "prekey" consisting of random data (currently 16KB). Attackers must recover the entire prekey with high accuracy before they can attempt to decrypt the shielded private key, but the current generation of attacks have bit error rates that, when applied cumulatively to the entire prekey, make this unlikely. Implementation-wise, keys are encrypted "shielded" when loaded and then automatically and transparently unshielded when used for signatures or when being saved/serialised. Hopefully we can remove this in a few years time when computer architecture has become less unsafe. been in snaps for a bit already; thanks deraadt@ ok dtucker@ deraadt@
2019-05-03Free host on exit path. Patch from markus at blueflash.cc, ok djm@Darren Tucker
2019-02-27dup stdout/in for proxycommand=-, otherwise stdout might beMarkus Friedl
redirected to /dev/null; ok djm@