summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-03-26 13:04:51 +1000
committerDamien Miller <djm@mindrot.org>2000-03-26 13:04:51 +1000
commit450a7a1ff40fe7c2d84c93b83cf2df53445d807d (patch)
treedb6d08bdea65edd34ba2e323a31e2b1ca5e5fbd4
parent2c9279fa667827384fceb243f890cba1dbe480de (diff)
- OpenBSD CVS update
- [auth-krb4.c] -Wall - [auth-rh-rsa.c auth-rsa.c hostfile.c hostfile.h key.c key.h match.c] [match.h ssh.c ssh.h sshconnect.c sshd.c] initial support for DSA keys. ok deraadt@, niels@ - [cipher.c cipher.h] remove unused cipher_attack_detected code - [scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh.1 sshd.8] Fix some formatting problems I missed before. - [ssh.1 sshd.8] fix spelling errors, From: FreeBSD - [ssh.c] switch to raw mode only if he _get_ a pty (not if we _want_ a pty).
-rw-r--r--ChangeLog14
-rw-r--r--Makefile.in2
-rw-r--r--README.Ylonen4
-rw-r--r--auth-krb4.c2
-rw-r--r--auth-rh-rsa.c49
-rw-r--r--auth-rsa.c37
-rw-r--r--cipher.c16
-rw-r--r--cipher.h8
-rw-r--r--hostfile.c202
-rw-r--r--hostfile.h22
-rw-r--r--key.c301
-rw-r--r--key.h23
-rw-r--r--match.c61
-rw-r--r--match.h18
-rw-r--r--scp.129
-rw-r--r--ssh-add.133
-rw-r--r--ssh-agent.152
-rw-r--r--ssh-keygen.162
-rw-r--r--ssh.136
-rw-r--r--ssh.c13
-rw-r--r--ssh.h36
-rw-r--r--sshconnect.c72
-rw-r--r--sshd.8388
-rw-r--r--sshd.c30
24 files changed, 965 insertions, 545 deletions
diff --git a/ChangeLog b/ChangeLog
index 17f3e66d..2462417d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,20 @@
- Better tests for OpenSSL w/ RSAref
- Added replacement setenv() function from OpenBSD libc. Suggested by
Ben Lindstrom <mouring@pconline.com>
+ - OpenBSD CVS update
+ - [auth-krb4.c]
+ -Wall
+ - [auth-rh-rsa.c auth-rsa.c hostfile.c hostfile.h key.c key.h match.c]
+ [match.h ssh.c ssh.h sshconnect.c sshd.c]
+ initial support for DSA keys. ok deraadt@, niels@
+ - [cipher.c cipher.h]
+ remove unused cipher_attack_detected code
+ - [scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh.1 sshd.8]
+ Fix some formatting problems I missed before.
+ - [ssh.1 sshd.8]
+ fix spelling errors, From: FreeBSD
+ - [ssh.c]
+ switch to raw mode only if he _get_ a pty (not if we _want_ a pty).
20000324
- Released 1.2.3
diff --git a/Makefile.in b/Makefile.in
index 5db02beb..6fee608d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -31,7 +31,7 @@ LDFLAGS=-L. @LDFLAGS@
TARGETS=ssh sshd ssh-add ssh-keygen ssh-agent scp $(EXTRA_TARGETS)
-LIBOBJS= atomicio.o authfd.o authfile.o bsd-bindresvport.o bsd-daemon.o bsd-misc.o bsd-mktemp.o bsd-rresvport.o bsd-setenv.o bsd-snprintf.o bsd-strlcat.o bsd-strlcpy.o bufaux.o buffer.o canohost.o channels.o cipher.o compat.o compress.o crc32.o deattack.o fake-getaddrinfo.o fake-getnameinfo.o fingerprint.o hostfile.o log.o match.o mpaux.o nchan.o packet.o radix.o random.o readpass.o rsa.o tildexpand.o ttymodes.o uidswap.o xmalloc.o
+LIBOBJS= atomicio.o authfd.o authfile.o bsd-bindresvport.o bsd-daemon.o bsd-misc.o bsd-mktemp.o bsd-rresvport.o bsd-setenv.o bsd-snprintf.o bsd-strlcat.o bsd-strlcpy.o bufaux.o buffer.o canohost.o channels.o cipher.o compat.o compress.o crc32.o deattack.o fake-getaddrinfo.o fake-getnameinfo.o fingerprint.o hostfile.o key.o log.o match.o mpaux.o nchan.o packet.o radix.o random.o readpass.o rsa.o tildexpand.o ttymodes.o uidswap.o xmalloc.o
SSHOBJS= ssh.o sshconnect.o log-client.o readconf.o clientloop.o
diff --git a/README.Ylonen b/README.Ylonen
index ed360844..38987b92 100644
--- a/README.Ylonen
+++ b/README.Ylonen
@@ -1,3 +1,7 @@
+
+[ Please note that this file has not been updated for OpenSSH and
+ covers the ssh-1.2.12 release from Dec 1995 only. ]
+
Ssh (Secure Shell) is a program to log into another computer over a
network, to execute commands in a remote machine, and to move files
from one machine to another. It provides strong authentication and
diff --git a/auth-krb4.c b/auth-krb4.c
index 95fc7229..7e30646f 100644
--- a/auth-krb4.c
+++ b/auth-krb4.c
@@ -139,7 +139,7 @@ int
krb4_init(uid_t uid)
{
static int cleanup_registered = 0;
- char *tkt_root = TKT_ROOT;
+ const char *tkt_root = TKT_ROOT;
struct stat st;
int fd;
diff --git a/auth-rh-rsa.c b/auth-rh-rsa.c
index 1392455c..19782577 100644
--- a/auth-rh-rsa.c
+++ b/auth-rh-rsa.c
@@ -15,7 +15,18 @@
*/
#include "includes.h"
-RCSID("$Id: auth-rh-rsa.c,v 1.7 1999/11/25 00:54:57 damien Exp $");
+RCSID("$Id: auth-rh-rsa.c,v 1.8 2000/03/26 03:04:52 damien Exp $");
+
+#ifdef HAVE_OPENSSL
+#include <openssl/bn.h>
+#include <openssl/rsa.h>
+#include <openssl/dsa.h>
+#endif
+#ifdef HAVE_SSL
+#include <ssl/bn.h>
+#include <ssl/rsa.h>
+#include <ssl/dsa.h>
+#endif
#include "packet.h"
#include "ssh.h"
@@ -23,37 +34,44 @@ RCSID("$Id: auth-rh-rsa.c,v 1.7 1999/11/25 00:54:57 damien Exp $");
#include "uidswap.h"
#include "servconf.h"
+#include "key.h"
+#include "hostfile.h"
+
/*
* Tries to authenticate the user using the .rhosts file and the host using
* its host key. Returns true if authentication succeeds.
*/
int
-auth_rhosts_rsa(struct passwd *pw, const char *client_user,
- BIGNUM *client_host_key_e, BIGNUM *client_host_key_n)
+auth_rhosts_rsa(struct passwd *pw, const char *client_user, RSA *client_host_key)
{
extern ServerOptions options;
const char *canonical_hostname;
HostStatus host_status;
- BIGNUM *ke, *kn;
+ Key *client_key, *found;
debug("Trying rhosts with RSA host authentication for %.100s", client_user);
+ if (client_host_key == NULL)
+ return 0;
+
/* Check if we would accept it using rhosts authentication. */
if (!auth_rhosts(pw, client_user))
return 0;
canonical_hostname = get_canonical_hostname();
- debug("Rhosts RSA authentication: canonical host %.900s",
- canonical_hostname);
+ debug("Rhosts RSA authentication: canonical host %.900s", canonical_hostname);
+
+ /* wrap the RSA key into a 'generic' key */
+ client_key = key_new(KEY_RSA);
+ BN_copy(client_key->rsa->e, client_host_key->e);
+ BN_copy(client_key->rsa->n, client_host_key->n);
+ found = key_new(KEY_RSA);
/* Check if we know the host and its host key. */
- ke = BN_new();
- kn = BN_new();
host_status = check_host_in_hostfile(SSH_SYSTEM_HOSTFILE, canonical_hostname,
- client_host_key_e, client_host_key_n,
- ke, kn);
+ client_key, found);
/* Check user host file unless ignored. */
if (host_status != HOST_OK && !options.ignore_user_known_hosts) {
@@ -73,14 +91,13 @@ auth_rhosts_rsa(struct passwd *pw, const char *client_user,
/* XXX race between stat and the following open() */
temporarily_use_uid(pw->pw_uid);
host_status = check_host_in_hostfile(user_hostfile, canonical_hostname,
- client_host_key_e, client_host_key_n,
- ke, kn);
+ client_key, found);
restore_uid();
}
xfree(user_hostfile);
}
- BN_free(ke);
- BN_free(kn);
+ key_free(client_key);
+ key_free(found);
if (host_status != HOST_OK) {
debug("Rhosts with RSA host authentication denied: unknown or invalid host key");
@@ -90,7 +107,7 @@ auth_rhosts_rsa(struct passwd *pw, const char *client_user,
/* A matching host key was found and is known. */
/* Perform the challenge-response dialog with the client for the host key. */
- if (!auth_rsa_challenge_dialog(client_host_key_e, client_host_key_n)) {
+ if (!auth_rsa_challenge_dialog(client_host_key)) {
log("Client on %.800s failed to respond correctly to host authentication.",
canonical_hostname);
return 0;
@@ -101,7 +118,7 @@ auth_rhosts_rsa(struct passwd *pw, const char *client_user,
*/
verbose("Rhosts with RSA host authentication accepted for %.100s, %.100s on %.700s.",
- pw->pw_name, client_user, canonical_hostname);
+ pw->pw_name, client_user, canonical_hostname);
packet_send_debug("Rhosts with RSA host authentication accepted.");
return 1;
}
diff --git a/auth-rsa.c b/auth-rsa.c
index ef7a2274..22ac09c4 100644
--- a/auth-rsa.c
+++ b/auth-rsa.c
@@ -16,7 +16,7 @@
*/
#include "includes.h"
-RCSID("$Id: auth-rsa.c,v 1.13 2000/03/09 10:27:50 damien Exp $");
+RCSID("$Id: auth-rsa.c,v 1.14 2000/03/26 03:04:52 damien Exp $");
#include "rsa.h"
#include "packet.h"
@@ -24,6 +24,7 @@ RCSID("$Id: auth-rsa.c,v 1.13 2000/03/09 10:27:50 damien Exp $");
#include "ssh.h"
#include "mpaux.h"
#include "uidswap.h"
+#include "match.h"
#include "servconf.h"
#ifdef HAVE_OPENSSL
@@ -66,10 +67,9 @@ extern unsigned char session_id[16];
*/
int
-auth_rsa_challenge_dialog(BIGNUM *e, BIGNUM *n)
+auth_rsa_challenge_dialog(RSA *pk)
{
BIGNUM *challenge, *encrypted_challenge;
- RSA *pk;
BN_CTX *ctx;
unsigned char buf[32], mdbuf[16], response[16];
MD5_CTX md;
@@ -82,19 +82,11 @@ auth_rsa_challenge_dialog(BIGNUM *e, BIGNUM *n)
/* Generate a random challenge. */
BN_rand(challenge, 256, 0, 0);
ctx = BN_CTX_new();
- BN_mod(challenge, challenge, n, ctx);
+ BN_mod(challenge, challenge, pk->n, ctx);
BN_CTX_free(ctx);
- /* Create the public key data structure. */
- pk = RSA_new();
- pk->e = BN_new();
- BN_copy(pk->e, e);
- pk->n = BN_new();
- BN_copy(pk->n, n);
-
/* Encrypt the challenge with the public key. */
rsa_public_encrypt(encrypted_challenge, challenge, pk);
- RSA_free(pk);
/* Send the encrypted challenge to the client. */
packet_start(SSH_SMSG_AUTH_RSA_CHALLENGE);
@@ -146,7 +138,7 @@ auth_rsa(struct passwd *pw, BIGNUM *client_n)
FILE *f;
unsigned long linenum = 0;
struct stat st;
- BIGNUM *e, *n;
+ RSA *pk;
/* Temporarily use the user's uid. */
temporarily_use_uid(pw->pw_uid);
@@ -208,8 +200,9 @@ auth_rsa(struct passwd *pw, BIGNUM *client_n)
/* Flag indicating whether authentication has succeeded. */
authenticated = 0;
- e = BN_new();
- n = BN_new();
+ pk = RSA_new();
+ pk->e = BN_new();
+ pk->n = BN_new();
/*
* Go though the accepted keys, looking for the current key. If
@@ -247,7 +240,7 @@ auth_rsa(struct passwd *pw, BIGNUM *client_n)
options = NULL;
/* Parse the key from the line. */
- if (!auth_rsa_read_key(&cp, &bits, e, n)) {
+ if (!auth_rsa_read_key(&cp, &bits, pk->e, pk->n)) {
debug("%.100s, line %lu: bad key syntax",
SSH_USER_PERMITTED_KEYS, linenum);
packet_send_debug("%.100s, line %lu: bad key syntax",
@@ -257,19 +250,20 @@ auth_rsa(struct passwd *pw, BIGNUM *client_n)
/* cp now points to the comment part. */
/* Check if the we have found the desired key (identified by its modulus). */
- if (BN_cmp(n, client_n) != 0)
+ if (BN_cmp(pk->n, client_n) != 0)
continue;
/* check the real bits */
- if (bits != BN_num_bits(n))
+ if (bits != BN_num_bits(pk->n))
log("Warning: %s, line %ld: keysize mismatch: "
"actual %d vs. announced %d.",
- file, linenum, BN_num_bits(n), bits);
+ file, linenum, BN_num_bits(pk->n), bits);
/* We have found the desired key. */
+
/* Perform the challenge-response dialog for this key. */
- if (!auth_rsa_challenge_dialog(e, n)) {
+ if (!auth_rsa_challenge_dialog(pk)) {
/* Wrong response. */
verbose("Wrong response to RSA authentication challenge.");
packet_send_debug("Wrong response to RSA authentication challenge.");
@@ -472,8 +466,7 @@ auth_rsa(struct passwd *pw, BIGNUM *client_n)
/* Close the file. */
fclose(f);
- BN_clear_free(n);
- BN_clear_free(e);
+ RSA_free(pk);
if (authenticated)
packet_send_debug("RSA authentication accepted.");
diff --git a/cipher.c b/cipher.c
index c55c7dcb..bf1518de 100644
--- a/cipher.c
+++ b/cipher.c
@@ -12,7 +12,7 @@
*/
#include "includes.h"
-RCSID("$Id: cipher.c,v 1.13 2000/03/09 10:27:50 damien Exp $");
+RCSID("$Id: cipher.c,v 1.14 2000/03/26 03:04:52 damien Exp $");
#include "ssh.h"
#include "cipher.h"
@@ -110,18 +110,6 @@ swap_bytes(const unsigned char *src, unsigned char *dst_, int n)
}
}
-void (*cipher_attack_detected) (const char *fmt,...) = fatal;
-
-static inline void
-detect_cbc_attack(const unsigned char *src,
- unsigned int len)
-{
- return;
-
- log("CRC-32 CBC insertion attack detected");
- cipher_attack_detected("CRC-32 CBC insertion attack detected");
-}
-
/*
* Names of all encryption algorithms.
* These must match the numbers defined in cipher.h.
@@ -304,7 +292,6 @@ cipher_decrypt(CipherContext *context, unsigned char *dest,
break;
case SSH_CIPHER_3DES:
- /* CRC-32 attack? */
SSH_3CBC_DECRYPT(context->u.des3.key1,
context->u.des3.key2, &context->u.des3.iv2,
context->u.des3.key3, &context->u.des3.iv3,
@@ -312,7 +299,6 @@ cipher_decrypt(CipherContext *context, unsigned char *dest,
break;
case SSH_CIPHER_BLOWFISH:
- detect_cbc_attack(src, len);
swap_bytes(src, dest, len);
BF_cbc_encrypt((void *) dest, dest, len,
&context->u.bf.key, context->u.bf.iv,
diff --git a/cipher.h b/cipher.h
index 79e8fb87..c323a6c5 100644
--- a/cipher.h
+++ b/cipher.h
@@ -11,7 +11,7 @@
*
*/
-/* RCSID("$Id: cipher.h,v 1.5 1999/11/25 00:54:58 damien Exp $"); */
+/* RCSID("$Id: cipher.h,v 1.6 2000/03/26 03:04:52 damien Exp $"); */
#ifndef CIPHER_H
#define CIPHER_H
@@ -96,10 +96,4 @@ void
cipher_decrypt(CipherContext * context, unsigned char *dest,
const unsigned char *src, unsigned int len);
-/*
- * If and CRC-32 attack is detected this function is called. Defaults to
- * fatal, changed to packet_disconnect in sshd and ssh.
- */
-extern void (*cipher_attack_detected) (const char *fmt, ...);
-
#endif /* CIPHER_H */
diff --git a/hostfile.c b/hostfile.c
index ea92fa04..a6684fa2 100644
--- a/hostfile.c
+++ b/hostfile.c
@@ -14,63 +14,32 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: hostfile.c,v 1.13 2000/02/18 10:20:20 markus Exp $");
+RCSID("$OpenBSD: hostfile.c,v 1.14 2000/03/23 22:15:33 markus Exp $");
+
+#ifdef HAVE_OPENSSL
+#include <openssl/bn.h>
+#include <openssl/rsa.h>
+#include <openssl/dsa.h>
+#endif
+#ifdef HAVE_SSL
+#include <ssl/bn.h>
+#include <ssl/rsa.h>
+#include <ssl/dsa.h>
+#endif
#include "packet.h"
+#include "match.h"
#include "ssh.h"
+#include "key.h"
+#include "hostfile.h"
/*
- * Reads a multiple-precision integer in decimal from the buffer, and advances
- * the pointer. The integer must already be initialized. This function is
- * permitted to modify the buffer. This leaves *cpp to point just beyond the
- * last processed (and maybe modified) character. Note that this may modify
- * the buffer containing the number.
+ * Parses an RSA (number of bits, e, n) or DSA key from a string. Moves the
+ * pointer over the key. Skips any whitespace at the beginning and at end.
*/
int
-auth_rsa_read_bignum(char **cpp, BIGNUM * value)
-{
- char *cp = *cpp;
- int old;
-
- /* Skip any leading whitespace. */
- for (; *cp == ' ' || *cp == '\t'; cp++)
- ;
-
- /* Check that it begins with a decimal digit. */
- if (*cp < '0' || *cp > '9')
- return 0;
-
- /* Save starting position. */
- *cpp = cp;
-
- /* Move forward until all decimal digits skipped. */
- for (; *cp >= '0' && *cp <= '9'; cp++)
- ;
-
- /* Save the old terminating character, and replace it by \0. */
- old = *cp;
- *cp = 0;
-
- /* Parse the number. */
- if (BN_dec2bn(&value, *cpp) == 0)
- return 0;
-
- /* Restore old terminating character. */
- *cp = old;
-
- /* Move beyond the number and return success. */
- *cpp = cp;
- return 1;
-}
-
-/*
- * Parses an RSA key (number of bits, e, n) from a string. Moves the pointer
- * over the key. Skips any whitespace at the beginning and at end.
- */
-
-int
-auth_rsa_read_key(char **cpp, unsigned int *bitsp, BIGNUM * e, BIGNUM * n)
+hostfile_read_key(char **cpp, unsigned int *bitsp, Key *ret)
{
unsigned int bits;
char *cp;
@@ -85,12 +54,7 @@ auth_rsa_read_key(char **cpp, unsigned int *bitsp, BIGNUM * e, BIGNUM * n)
for (bits = 0; *cp >= '0' && *cp <= '9'; cp++)
bits = 10 * bits + *cp - '0';
- /* Get public exponent. */
- if (!auth_rsa_read_bignum(&cp, e))
- return 0;
-
- /* Get public modulus. */
- if (!auth_rsa_read_bignum(&cp, n))
+ if (!key_read(ret, bits, &cp))
return 0;
/* Skip trailing whitespace. */
@@ -103,63 +67,30 @@ auth_rsa_read_key(char **cpp, unsigned int *bitsp, BIGNUM * e, BIGNUM * n)
return 1;
}
-/*
- * Tries to match the host name (which must be in all lowercase) against the
- * comma-separated sequence of subpatterns (each possibly preceded by ! to
- * indicate negation). Returns true if there is a positive match; zero
- * otherwise.
- */
-
int
-match_hostname(const char *host, const char *pattern, unsigned int len)
+auth_rsa_read_key(char **cpp, unsigned int *bitsp, BIGNUM * e, BIGNUM * n)
{
- char sub[1024];
- int negated;
- int got_positive;
- unsigned int i, subi;
-
- got_positive = 0;
- for (i = 0; i < len;) {
- /* Check if the subpattern is negated. */
- if (pattern[i] == '!') {
- negated = 1;
- i++;
- } else
- negated = 0;
-
- /*
- * Extract the subpattern up to a comma or end. Convert the
- * subpattern to lowercase.
- */
- for (subi = 0;
- i < len && subi < sizeof(sub) - 1 && pattern[i] != ',';
- subi++, i++)
- sub[subi] = isupper(pattern[i]) ? tolower(pattern[i]) : pattern[i];
- /* If subpattern too long, return failure (no match). */
- if (subi >= sizeof(sub) - 1)
- return 0;
-
- /* If the subpattern was terminated by a comma, skip the comma. */
- if (i < len && pattern[i] == ',')
- i++;
-
- /* Null-terminate the subpattern. */
- sub[subi] = '\0';
+ Key *k = key_new(KEY_RSA);
+ int ret = hostfile_read_key(cpp, bitsp, k);
+ BN_copy(e, k->rsa->e);
+ BN_copy(n, k->rsa->n);
+ key_free(k);
+ return ret;
+}
- /* Try to match the subpattern against the host name. */
- if (match_pattern(host, sub)) {
- if (negated)
- return 0; /* Fail */
- else
- got_positive = 1;
- }
+int
+hostfile_check_key(int bits, Key *key, const char *host, const char *filename, int linenum)
+{
+ if (key == NULL || key->type != KEY_RSA || key->rsa == NULL)
+ return 1;
+ if (bits != BN_num_bits(key->rsa->n)) {
+ error("Warning: %s, line %d: keysize mismatch for host %s: "
+ "actual %d vs. announced %d.",
+ filename, linenum, host, BN_num_bits(key->rsa->n), bits);
+ error("Warning: replace %d with %d in %s, line %d.",
+ bits, BN_num_bits(key->rsa->n), filename, linenum);
}
-
- /*
- * Return success if got a positive match. If there was a negative
- * match, we have already returned zero and never get here.
- */
- return got_positive;
+ return 1;
}
/*
@@ -170,8 +101,7 @@ match_hostname(const char *host, const char *pattern, unsigned int len)
*/
HostStatus
-check_host_in_hostfile(const char *filename, const char *host,
- BIGNUM * e, BIGNUM * n, BIGNUM * ke, BIGNUM * kn)
+check_host_in_hostfile(const char *filename, const char *host, Key *key, Key *found)
{
FILE *f;
char line[8192];
@@ -180,6 +110,8 @@ check_host_in_hostfile(const char *filename, const char *host,
char *cp, *cp2;
HostStatus end_return;
+ if (key == NULL)
+ fatal("no key to look up");
/* Open the file containing the list of known hosts. */
f = fopen(filename, "r");
if (!f)
@@ -221,18 +153,13 @@ check_host_in_hostfile(const char *filename, const char *host,
* Extract the key from the line. This will skip any leading
* whitespace. Ignore badly formatted lines.
*/
- if (!auth_rsa_read_key(&cp, &kbits, ke, kn))
+ if (!hostfile_read_key(&cp, &kbits, found))
+ continue;
+ if (!hostfile_check_key(kbits, found, host, filename, linenum))
continue;
- if (kbits != BN_num_bits(kn)) {
- error("Warning: %s, line %d: keysize mismatch for host %s: "
- "actual %d vs. announced %d.",
- filename, linenum, host, BN_num_bits(kn), kbits);
- error("Warning: replace %d with %d in %s, line %d.",
- kbits, BN_num_bits(kn), filename, linenum);
- }
/* Check if the current key is the same as the given key. */
- if (BN_cmp(ke, e) == 0 && BN_cmp(kn, n) == 0) {
+ if (key_equal(key, found)) {
/* Ok, they match. */
fclose(f);
return HOST_OK;
@@ -260,41 +187,28 @@ check_host_in_hostfile(const char *filename, const char *host,
*/
int
-add_host_to_hostfile(const char *filename, const char *host,
- BIGNUM * e, BIGNUM * n)
+add_host_to_hostfile(const char *filename, const char *host, Key *key)
{
FILE *f;
- char *buf;
- unsigned int bits;
+ int success = 0;
+
+ if (key == NULL)
+ return 1;
/* Open the file for appending. */
f = fopen(filename, "a");
if (!f)
return 0;
- /* size of modulus 'n' */
- bits = BN_num_bits(n);
-
- /* Print the host name and key to the file. */
- fprintf(f, "%s %u ", host, bits);
- buf = BN_bn2dec(e);
- if (buf == NULL) {
- error("add_host_to_hostfile: BN_bn2dec(e) failed");
- fclose(f);
- return 0;
+ fprintf(f, "%s ", host);
+ if (key_write(key, f)) {
+ fprintf(f, "\n");
+ success = 1;
+ } else {
+ error("add_host_to_hostfile: saving key failed");
}
- fprintf(f, "%s ", buf);
- free(buf);
- buf = BN_bn2dec(n);
- if (buf == NULL) {
- error("add_host_to_hostfile: BN_bn2dec(n) failed");
- fclose(f);
- return 0;
- }
- fprintf(f, "%s\n", buf);
- free(buf);
/* Close the file. */
fclose(f);
- return 1;
+ return success;
}
diff --git a/hostfile.h b/hostfile.h
new file mode 100644
index 00000000..64fe185d
--- /dev/null
+++ b/hostfile.h
@@ -0,0 +1,22 @@
+#ifndef HOSTFILE_H
+#define HOSTFILE_H
+
+/*
+ * Checks whether the given host is already in the list of our known hosts.
+ * Returns HOST_OK if the host is known and has the specified key, HOST_NEW
+ * if the host is not known, and HOST_CHANGED if the host is known but used
+ * to have a different host key. The host must be in all lowercase.
+ */
+typedef enum {
+ HOST_OK, HOST_NEW, HOST_CHANGED
+} HostStatus;
+HostStatus
+check_host_in_hostfile(const char *filename, const char *host, Key *key, Key *found);
+
+/*
+ * Appends an entry to the host file. Returns false if the entry could not
+ * be appended.
+ */
+int add_host_to_hostfile(const char *filename, const char *host, Key *key);
+
+#endif
diff --git a/key.c b/key.c
new file mode 100644
index 00000000..437a5e24
--- /dev/null
+++ b/key.c
@@ -0,0 +1,301 @@
+/*
+ * Copyright (c) 2000 Markus Friedl. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Markus Friedl.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * read_bignum():
+ * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
+ */
+
+#include "includes.h"
+
+#ifdef HAVE_OPENSSL
+#include <openssl/bn.h>
+#include <openssl/rsa.h>
+#include <openssl/dsa.h>
+#include <openssl/evp.h>
+#endif
+#ifdef HAVE_SSL
+#include <ssl/bn.h>
+#include <ssl/rsa.h>
+#include <ssl/dsa.h>
+#include <ssl/evp.h>
+#endif
+
+#include "ssh.h"
+#include "xmalloc.h"
+#include "key.h"
+
+Key *
+key_new(int type)
+{
+ Key *k;
+ RSA *rsa;
+ DSA *dsa;
+ k = xmalloc(sizeof(*k));
+ k->type = type;
+ switch (k->type) {
+ case KEY_RSA:
+ rsa = RSA_new();
+ rsa->n = BN_new();
+ rsa->e = BN_new();
+ k->rsa = rsa;
+ break;
+ case KEY_DSA:
+ dsa = DSA_new();
+ dsa->p = BN_new();
+ dsa->q = BN_new();
+ dsa->g = BN_new();
+ dsa->pub_key = BN_new();
+ k->dsa = dsa;
+ break;
+ case KEY_EMPTY:
+ k->dsa = NULL;
+ k->rsa = NULL;
+ break;
+ default:
+ fatal("key_new: bad key type %d", k->type);
+ break;
+ }
+ return k;
+}
+void
+key_free(Key *k)
+{
+ switch (k->type) {
+ case KEY_RSA:
+ if (k->rsa != NULL)
+ RSA_free(k->rsa);
+ k->rsa = NULL;
+ break;
+ case KEY_DSA:
+ if (k->dsa != NULL)
+ DSA_free(k->dsa);
+ k->dsa = NULL;
+ break;
+ default:
+ fatal("key_free: bad key type %d", k->type);
+ break;
+ }
+ xfree(k);
+}
+int
+key_equal(Key *a, Key *b)
+{
+ if (a == NULL || b == NULL || a->type != b->type)
+ return 0;
+ switch (a->type) {
+ case KEY_RSA:
+ return a->rsa != NULL && b->rsa != NULL &&
+ BN_cmp(a->rsa->e, b->rsa->e) == 0 &&
+ BN_cmp(a->rsa->n, b->rsa->n) == 0;
+ break;
+ case KEY_DSA:
+ return a->dsa != NULL && b->dsa != NULL &&
+ BN_cmp(a->dsa->p, b->dsa->p) == 0 &&
+ BN_cmp(a->dsa->q, b->dsa->q) == 0 &&
+ BN_cmp(a->dsa->g, b->dsa->g) == 0 &&
+ BN_cmp(a->dsa->pub_key, b->dsa->pub_key) == 0;
+ break;
+ default:
+ fatal("key_free: bad key type %d", a->type);
+ break;
+ }
+ return 0;
+}
+
+#define FPRINT "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x"
+
+/*
+ * Generate key fingerprint in ascii format.
+ * Based on ideas and code from Bjoern Groenvall <bg@sics.se>
+ */
+char *
+key_fingerprint(Key *k)
+{
+ static char retval[80];
+ unsigned char *buf = NULL;
+ int len = 0;
+ int nlen, elen, plen, qlen, glen, publen;
+
+ switch (k->type) {
+ case KEY_RSA:
+ nlen = BN_num_bytes(k->rsa->n);
+ elen = BN_num_bytes(k->rsa->e);
+ len = nlen + elen;
+ buf = xmalloc(len);
+ BN_bn2bin(k->rsa->n, buf);
+ BN_bn2bin(k->rsa->e, buf + nlen);
+ break;
+ case KEY_DSA:
+ plen = BN_num_bytes(k->dsa->p);
+ qlen = BN_num_bytes(k->dsa->q);
+ glen = BN_num_bytes(k->dsa->g);
+ publen = BN_num_bytes(k->dsa->pub_key);
+ len = qlen + qlen + glen + publen;
+ buf = xmalloc(len);
+ BN_bn2bin(k->dsa->p, buf);
+ BN_bn2bin(k->dsa->q, buf + plen);
+ BN_bn2bin(k->dsa->g, buf + plen + qlen);
+ BN_bn2bin(k->dsa->pub_key , buf + plen + qlen + glen);
+ break;
+ default:
+ fatal("key_fingerprint: bad key type %d", k->type);
+ break;
+ }
+ if (buf != NULL) {
+ unsigned char d[16];
+ EVP_MD_CTX md;
+ EVP_DigestInit(&md, EVP_md5());
+ EVP_DigestUpdate(&md, buf, len);
+ EVP_DigestFinal(&md, d, NULL);
+ snprintf(retval, sizeof(retval), FPRINT,
+ d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],
+ d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
+ memset(buf, 0, len);
+ xfree(buf);
+ }
+ return retval;
+}
+
+/*
+ * Reads a multiple-precision integer in decimal from the buffer, and advances
+ * the pointer. The integer must already be initialized. This function is
+ * permitted to modify the buffer. This leaves *cpp to point just beyond the
+ * last processed (and maybe modified) character. Note that this may modify
+ * the buffer containing the number.
+ */
+int
+read_bignum(char **cpp, BIGNUM * value)
+{
+ char *cp = *cpp;
+ int old;
+
+ /* Skip any leading whitespace. */
+ for (; *cp == ' ' || *cp == '\t'; cp++)
+ ;
+
+ /* Check that it begins with a decimal digit. */
+ if (*cp < '0' || *cp > '9')
+ return 0;
+
+ /* Save starting position. */
+ *cpp = cp;
+
+ /* Move forward until all decimal digits skipped. */
+ for (; *cp >= '0' && *cp <= '9'; cp++)
+ ;
+
+ /* Save the old terminating character, and replace it by \0. */
+ old = *cp;
+ *cp = 0;
+
+ /* Parse the number. */
+ if (BN_dec2bn(&value, *cpp) == 0)
+ return 0;
+
+ /* Restore old terminating character. */
+ *cp = old;
+
+ /* Move beyond the number and return success. */
+ *cpp = cp;
+ return 1;
+}
+int
+write_bignum(FILE *f, BIGNUM *num)
+{
+ char *buf = BN_bn2dec(num);
+ if (buf == NULL) {
+ error("write_bignum: BN_bn2dec() failed");
+ return 0;
+ }
+ fprintf(f, " %s", buf);
+ free(buf);
+ return 1;
+}
+int
+key_read(Key *ret, unsigned int bits, char **cpp)
+{
+ switch(ret->type) {
+ case KEY_RSA:
+ if (bits == 0)
+ return 0;
+ /* Get public exponent, public modulus. */
+ if (!read_bignum(cpp, ret->rsa->e))
+ return 0;
+ if (!read_bignum(cpp, ret->rsa->n))
+ return 0;
+ break;
+ case KEY_DSA:
+ if (bits != 0)
+ return 0;
+ if (!read_bignum(cpp, ret->dsa->p))
+ return 0;
+ if (!read_bignum(cpp, ret->dsa->q))
+ return 0;
+ if (!read_bignum(cpp, ret->dsa->g))
+ return 0;
+ if (!read_bignum(cpp, ret->dsa->pub_key))
+ return 0;
+ break;
+ default:
+ fatal("bad key type: %d", ret->type);
+ break;
+ }
+ return 1;
+}
+int
+key_write(Key *key, FILE *f)
+{
+ int success = 0;
+ unsigned int bits = 0;
+
+ if (key->type == KEY_RSA && key->rsa != NULL) {
+ /* size of modulus 'n' */
+ bits = BN_num_bits(key->rsa->n);
+ fprintf(f, "%u", bits);
+ if (write_bignum(f, key->rsa->e) &&
+ write_bignum(f, key->rsa->n)) {
+ success = 1;
+ } else {
+ error("key_write: failed for RSA key");
+ }
+ } else if (key->type == KEY_DSA && key->dsa != NULL) {
+ /* bits == 0 means DSA key */
+ bits = 0;
+ fprintf(f, "%u", bits);
+ if (write_bignum(f, key->dsa->p) &&
+ write_bignum(f, key->dsa->q) &&
+ write_bignum(f, key->dsa->g) &&
+ write_bignum(f, key->dsa->pub_key)) {
+ success = 1;
+ } else {
+ error("key_write: failed for DSA key");
+ }
+ }
+ return success;
+}
diff --git a/key.h b/key.h
new file mode 100644
index 00000000..70f0c518
--- /dev/null
+++ b/key.h
@@ -0,0 +1,23 @@
+#ifndef KEY_H
+#define KEY_H
+
+typedef struct Key Key;
+enum types {
+ KEY_RSA,
+ KEY_DSA,
+ KEY_EMPTY
+};
+struct Key {
+ int type;
+ RSA *rsa;
+ DSA *dsa;
+};
+
+Key *key_new(int type);
+void key_free(Key *k);
+int key_equal(Key *a, Key *b);
+char *key_fingerprint(Key *k);
+int key_write(Key *key, FILE *f);
+int key_read(Key *key, unsigned int bits, char **cpp);
+
+#endif
diff --git a/match.c b/match.c
index 5386df6c..b72efca7 100644
--- a/match.c
+++ b/match.c
@@ -14,7 +14,7 @@
*/
#include "includes.h"
-RCSID("$Id: match.c,v 1.3 1999/11/25 00:54:59 damien Exp $");
+RCSID("$Id: match.c,v 1.4 2000/03/26 03:04:53 damien Exp $");
#include "ssh.h"
@@ -80,3 +80,62 @@ match_pattern(const char *s, const char *pattern)
}
/* NOTREACHED */
}
+
+/*
+ * Tries to match the host name (which must be in all lowercase) against the
+ * comma-separated sequence of subpatterns (each possibly preceded by ! to
+ * indicate negation). Returns true if there is a positive match; zero
+ * otherwise.
+ */
+
+int
+match_hostname(const char *host, const char *pattern, unsigned int len)
+{
+ char sub[1024];
+ int negated;
+ int got_positive;
+ unsigned int i, subi;
+
+ got_positive = 0;
+ for (i = 0; i < len;) {
+ /* Check if the subpattern is negated. */
+ if (pattern[i] == '!') {
+ negated = 1;
+ i++;
+ } else
+ negated = 0;
+
+ /*
+ * Extract the subpattern up to a comma or end. Convert the
+ * subpattern to lowercase.
+ */
+ for (subi = 0;
+ i < len && subi < sizeof(sub) - 1 && pattern[i] != ',';
+ subi++, i++)
+ sub[subi] = isupper(pattern[i]) ? tolower(pattern[i]) : pattern[i];
+ /* If subpattern too long, return failure (no match). */
+ if (subi >= sizeof(sub) - 1)
+ return 0;
+
+ /* If the subpattern was terminated by a comma, skip the comma. */
+ if (i < len && pattern[i] == ',')
+ i++;
+
+ /* Null-terminate the subpattern. */
+ sub[subi] = '\0';
+
+ /* Try to match the subpattern against the host name. */
+ if (match_pattern(host, sub)) {
+ if (negated)
+ return 0; /* Fail */
+ else
+ got_positive = 1;
+ }
+ }
+
+ /*
+ * Return success if got a positive match. If there was a negative
+ * match, we have already returned zero and never get here.
+ */
+ return got_positive;
+}
diff --git a/match.h b/match.h
new file mode 100644
index 00000000..4625d976
--- /dev/null
+++ b/match.h
@@ -0,0 +1,18 @@
+#ifndef MATCH_H
+#define MATCH_H
+
+/*
+ * Returns true if the given string matches the pattern (which may contain ?
+ * and * as wildcards), and zero if it does not match.
+ */
+int match_pattern(const char *s, const char *pattern);
+
+/*
+ * Tries to match the host name (which must be in all lowercase) against the
+ * comma-separated sequence of subpatterns (each possibly preceded by ! to
+ * indicate negation). Returns true if there is a positive match; zero
+ * otherwise.
+ */
+int match_hostname(const char *host, const char *pattern, unsigned int len);
+
+#endif
diff --git a/scp.1 b/scp.1
index b9f68615..5604cb80 100644
--- a/scp.1
+++ b/scp.1
@@ -9,7 +9,7 @@
.\"
.\" Created: Sun May 7 00:14:37 1995 ylo
.\"
-.\" $Id: scp.1,v 1.5 2000/01/20 12:13:36 damien Exp $
+.\" $Id: scp.1,v 1.6 2000/03/26 03:04:53 damien Exp $
.\"
.Dd September 25, 1999
.Dt SCP 1
@@ -38,7 +38,8 @@
.Sm on
.Sh DESCRIPTION
.Nm
-copies files between hosts on a network. It uses
+copies files between hosts on a network.
+It uses
.Xr ssh 1
for data transfer, and uses the same authentication and provides the
same security as
@@ -50,18 +51,19 @@ will ask for passwords or passphrases if they are needed for
authentication.
.Pp
Any file name may contain a host and user specification to indicate
-that the file is to be copied to/from that host. Copies between two
-remote hosts are permitted.
+that the file is to be copied to/from that host.
+Copies between two remote hosts are permitted.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl c Ar cipher
-Selects the cipher to use for encrypting the data transfer. This
-option is directly passed to
+Selects the cipher to use for encrypting the data transfer.
+This option is directly passed to
.Xr ssh 1 .
.It Fl i Ar identity_file
Selects the file from which the identity (private key) for RSA
-authentication is read. This option is directly passed to
+authentication is read.
+This option is directly passed to
.Xr ssh 1 .
.It Fl p
Preserves modification times, access times, and modes from the
@@ -69,25 +71,28 @@ original file.
.It Fl r
Recursively copy entire directories.
.It Fl v
-Verbose mode. Causes
+Verbose mode.
+Causes
.Nm
and
.Xr ssh 1
-to print debugging messages about their progress. This is helpful in
+to print debugging messages about their progress.
+This is helpful in
debugging connection, authentication, and configuration problems.
.It Fl B
Selects batch mode (prevents asking for passwords or passphrases).
.It Fl q
Disables the progress meter.
.It Fl C
-Compression enable. Passes the
+Compression enable.
+Passes the
.Fl C
flag to
.Xr ssh 1
to enable compression.
.It Fl P Ar port
-Specifies the port to connect to on the remote host. Note that this
-option is written with a capital
+Specifies the port to connect to on the remote host.
+Note that this option is written with a capital
.Sq P ,
because
.Fl p
diff --git a/ssh-add.1 b/ssh-add.1
index e56140d1..6c35996b 100644
--- a/ssh-add.1
+++ b/ssh-add.1
@@ -9,7 +9,7 @@
.\"
.\" Created: Sat Apr 22 23:55:14 1995 ylo
.\"
-.\" $Id: ssh-add.1,v 1.9 2000/01/22 08:57:40 damien Exp $
+.\" $Id: ssh-add.1,v 1.10 2000/03/26 03:04:53 damien Exp $
.\"
.Dd September 25, 1999
.Dt SSH-ADD 1
@@ -27,11 +27,11 @@ adds identities to the authentication agent,
.Xr ssh-agent 1 .
When run without arguments, it adds the file
.Pa $HOME/.ssh/identity .
-Alternative file names can be given on the
-command line. If any file requires a passphrase,
+Alternative file names can be given on the command line.
+If any file requires a passphrase,
.Nm
asks for the passphrase from the user.
-The Passphrase it is read from the user's tty.
+The Passphrase it is read from the user's tty.
.Pp
The authentication agent must be running and must be an ancestor of
the current process for
@@ -52,15 +52,15 @@ Deletes all identities from the agent.
.Sh FILES
.Bl -tag -width Ds
.It Pa $HOME/.ssh/identity
-Contains the RSA authentication identity of the user. This file
-should not be readable by anyone but the user.
+Contains the RSA authentication identity of the user.
+This file should not be readable by anyone but the user.
Note that
.Nm
ignores this file if it is accessible by others.
It is possible to
specify a passphrase when generating the key; that passphrase will be
-used to encrypt the private part of this file. This is the
-default file added by
+used to encrypt the private part of this file.
+This is the default file added by
.Nm
when no other files have been specified.
.Pp
@@ -70,7 +70,8 @@ when no other files have been specified.
If
.Nm
needs a passphrase, it will read the passphrase from the current
-terminal if it was run from a terminal. If
+terminal if it was run from a terminal.
+If
.Nm
does not have a terminal associated with it but
.Ev DISPLAY
@@ -78,12 +79,13 @@ and
.Ev SSH_ASKPASS
are set, it will execute the program specified by
.Ev SSH_ASKPASS
-and open an X11 window to read the passphrase. This is particularly
-useful when calling
+and open an X11 window to read the passphrase.
+This is particularly useful when calling
.Nm
from a
.Pa .Xsession
-or related script. (Note that on some machines it
+or related script.
+(Note that on some machines it
may be necessary to redirect the input from
.Pa /dev/null
to make this work.)
@@ -92,9 +94,10 @@ Tatu Ylonen <ylo@cs.hut.fi>
.Pp
OpenSSH
is a derivative of the original (free) ssh 1.2.12 release, but with bugs
-removed and newer features re-added. Rapidly after the 1.2.12 release,
-newer versions bore successively more restrictive licenses. This version
-of OpenSSH
+removed and newer features re-added.
+Rapidly after the 1.2.12 release,
+newer versions bore successively more restrictive licenses.
+This version of OpenSSH
.Bl -bullet
.It
has all components of a restrictive nature (i.e., patents, see
diff --git a/ssh-agent.1 b/ssh-agent.1
index b98775d9..7029b60d 100644
--- a/ssh-agent.1
+++ b/ssh-agent.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ssh-agent.1,v 1.9 2000/01/22 02:17:50 aaron Exp $
+.\" $OpenBSD: ssh-agent.1,v 1.10 2000/03/23 21:10:10 aaron Exp $
.\"
.\" -*- nroff -*-
.\"
@@ -27,12 +27,13 @@
.Oc
.Sh DESCRIPTION
.Nm
-is a program to hold authentication private keys. The
-idea is that
+is a program to hold authentication private keys.
+The idea is that
.Nm
is started in the beginning of an X-session or a login session, and
all other windows or programs are started as clients to the ssh-agent
-program. Through use of environment variables the agent can be located
+program.
+Through use of environment variables the agent can be located
and automatically used for RSA authentication when logging in to other
machines using
.Xr ssh 1 .
@@ -60,30 +61,34 @@ environment variable).
If a commandline is given, this is executed as a subprocess of the agent.
When the command dies, so does the agent.
.Pp
-The agent initially does not have any private keys. Keys are added
-using
+The agent initially does not have any private keys.
+Keys are added using
.Xr ssh-add 1 .
When executed without arguments,
.Xr ssh-add 1
adds the
.Pa $HOME/.ssh/identity
-file. If the identity has a passphrase,
+file.
+If the identity has a passphrase,
.Xr ssh-add 1
asks for the passphrase (using a small X11 application if running
-under X11, or from the terminal if running without X). It then sends
-the identity to the agent. Several identities can be stored in the
+under X11, or from the terminal if running without X).
+It then sends the identity to the agent.
+Several identities can be stored in the
agent; the agent can automatically use any of these identities.
.Ic ssh-add -l
displays the identities currently held by the agent.
.Pp
The idea is that the agent is run in the user's local PC, laptop, or
-terminal. Authentication data need not be stored on any other
+terminal.
+Authentication data need not be stored on any other
machine, and authentication passphrases never go over the network.
However, the connection to the agent is forwarded over SSH
remote logins, and the user can thus use the privileges given by the
identities anywhere in the network in a secure way.
.Pp
-There are two main ways to get an agent setup: Either you let the agent
+There are two main ways to get an agent setup:
+Either you let the agent
start a new subcommand into which some environment variables are exported, or
you let the agent print the needed shell commands (either
.Xr sh 1
@@ -99,7 +104,8 @@ A unix-domain socket is created
and the name of this socket is stored in the
.Ev SSH_AUTH_SOCK
environment
-variable. The socket is made accessible only to the current user.
+variable.
+The socket is made accessible only to the current user.
This method is easily abused by root or another instance of the same
user.
.Pp
@@ -112,28 +118,30 @@ line terminates.
.Sh FILES
.Bl -tag -width Ds
.It Pa $HOME/.ssh/identity
-Contains the RSA authentication identity of the user. This file
-should not be readable by anyone but the user. It is possible to
+Contains the RSA authentication identity of the user.
+This file should not be readable by anyone but the user.
+It is possible to
specify a passphrase when generating the key; that passphrase will be
-used to encrypt the private part of this file. This file
-is not used by
+used to encrypt the private part of this file.
+This file is not used by
.Nm
but is normally added to the agent using
.Xr ssh-add 1
at login time.
.It Pa /tmp/ssh-XXXX/agent.<pid> ,
Unix-domain sockets used to contain the connection to the
-authentication agent. These sockets should only be readable by the
-owner. The sockets should get automatically removed when the agent
-exits.
+authentication agent.
+These sockets should only be readable by the owner.
+The sockets should get automatically removed when the agent exits.
.Sh AUTHOR
Tatu Ylonen <ylo@cs.hut.fi>
.Pp
OpenSSH
is a derivative of the original (free) ssh 1.2.12 release, but with bugs
-removed and newer features re-added. Rapidly after the 1.2.12 release,
-newer versions bore successively more restrictive licenses. This version
-of OpenSSH
+removed and newer features re-added.
+Rapidly after the 1.2.12 release,
+newer versions bore successively more restrictive licenses.
+This version of OpenSSH
.Bl -bullet
.It
has all components of a restrictive nature (i.e., patents, see
diff --git a/ssh-keygen.1 b/ssh-keygen.1
index 74fe8690..8474e8f9 100644
--- a/ssh-keygen.1
+++ b/ssh-keygen.1
@@ -9,7 +9,7 @@
.\"
.\" Created: Sat Apr 22 23:55:14 1995 ylo
.\"
-.\" $Id: ssh-keygen.1,v 1.9 2000/01/22 08:57:40 damien Exp $
+.\" $Id: ssh-keygen.1,v 1.10 2000/03/26 03:04:53 damien Exp $
.\"
.Dd September 25, 1999
.Dt SSH-KEYGEN 1
@@ -48,27 +48,31 @@ key in
Additionally, the system administrator may use this to generate host keys.
.Pp
Normally this program generates the key and asks for a file in which
-to store the private key. The public key is stored in a file with the
-same name but
+to store the private key.
+The public key is stored in a file with the same name but
.Dq .pub
-appended. The program also asks for a
-passphrase. The passphrase may be empty to indicate no passphrase
+appended.
+The program also asks for a passphrase.
+The passphrase may be empty to indicate no passphrase
(host keys must have empty passphrase), or it may be a string of
-arbitrary length. Good passphrases are 10-30 characters long and are
+arbitrary length.
+Good passphrases are 10-30 characters long and are
not simple sentences or otherwise easily guessable (English
prose has only 1-2 bits of entropy per word, and provides very bad
-passphrases). The passphrase can be changed later by using the
+passphrases).
+The passphrase can be changed later by using the
.Fl p
option.
.Pp
-There is no way to recover a lost passphrase. If the passphrase is
+There is no way to recover a lost passphrase.
+If the passphrase is
lost or forgotten, you will have to generate a new key and copy the
corresponding public key to other machines.
.Pp
There is also a comment field in the key file that is only for
-convenience to the user to help identify the key. The comment can
-tell what the key is for, or whatever is useful. The comment is
-initialized to
+convenience to the user to help identify the key.
+The comment can tell what the key is for, or whatever is useful.
+The comment is initialized to
.Dq user@host
when the key is created, but can be changed using the
.Fl c
@@ -77,10 +81,11 @@ option.
The options are as follows:
.Bl -tag -width Ds
.It Fl b Ar bits
-Specifies the number of bits in the key to create. Minimum is 512
-bits. Generally 1024 bits is considered sufficient, and key sizes
-above that no longer improve security but make things slower. The
-default is 1024 bits.
+Specifies the number of bits in the key to create.
+Minimum is 512 bits.
+Generally 1024 bits is considered sufficient, and key sizes
+above that no longer improve security but make things slower.
+The default is 1024 bits.
.It Fl c
Requests changing the comment in the private and public key files.
The program will prompt for the file containing the private keys, for
@@ -91,7 +96,8 @@ Specifies the filename of the key file.
Show fingerprint of specified private or public key file.
.It Fl p
Requests changing the passphrase of a private key file instead of
-creating a new private key. The program will prompt for the file
+creating a new private key.
+The program will prompt for the file
containing the private key, for the old passphrase, and twice for the
new passphrase.
.It Fl q
@@ -110,28 +116,30 @@ Provides the (old) passphrase.
.Sh FILES
.Bl -tag -width Ds
.It Pa $HOME/.ssh/identity
-Contains the RSA authentication identity of the user. This file
-should not be readable by anyone but the user. It is possible to
+Contains the RSA authentication identity of the user.
+This file should not be readable by anyone but the user.
+It is possible to
specify a passphrase when generating the key; that passphrase will be
-used to encrypt the private part of this file using 3DES. This file
-is not automatically accessed by
+used to encrypt the private part of this file using 3DES.
+This file is not automatically accessed by
.Nm
but it is offered as the default file for the private key.
.It Pa $HOME/.ssh/identity.pub
-Contains the public key for authentication. The contents of this file
-should be added to
+Contains the public key for authentication.
+The contents of this file should be added to
.Pa $HOME/.ssh/authorized_keys
on all machines
-where you wish to log in using RSA authentication. There is no
-need to keep the contents of this file secret.
+where you wish to log in using RSA authentication.
+There is no need to keep the contents of this file secret.
.Sh AUTHOR
Tatu Ylonen <ylo@cs.hut.fi>
.Pp
OpenSSH
is a derivative of the original (free) ssh 1.2.12 release, but with bugs
-removed and newer features re-added. Rapidly after the 1.2.12 release,
-newer versions bore successively more restrictive licenses. This version
-of OpenSSH
+removed and newer features re-added.
+Rapidly after the 1.2.12 release,
+newer versions bore successively more restrictive licenses.
+This version of OpenSSH
.Bl -bullet
.It
has all components of a restrictive nature (i.e., patents, see
diff --git a/ssh.1 b/ssh.1
index 0116977b..eba0e0f9 100644
--- a/ssh.1
+++ b/ssh.1
@@ -9,7 +9,7 @@
.\"
.\" Created: Sat Apr 22 21:55:14 1995 ylo
.\"
-.\" $Id: ssh.1,v 1.19 2000/03/17 12:40:17 damien Exp $
+.\" $Id: ssh.1,v 1.20 2000/03/26 03:04:54 damien Exp $
.\"
.Dd September 25, 1999
.Dt SSH 1
@@ -287,8 +287,8 @@ host key is not known or has changed.
.Sh OPTIONS
.Bl -tag -width Ds
.It Fl a
-Disables forwarding of the authentication agent connection. This may
-also be specified on a per-host basis in the configuration file.
+Disables forwarding of the authentication agent connection.
+This may also be specified on a per-host basis in the configuration file.
.It Fl c Ar blowfish|3des
Selects the cipher to use for encrypting the session.
.Ar 3des
@@ -342,8 +342,8 @@ It is possible to have multiple
options (and multiple identities specified in
configuration files).
.It Fl k
-Disables forwarding of Kerberos tickets and AFS tokens. This may
-also be specified on a per-host basis in the configuration file.
+Disables forwarding of Kerberos tickets and AFS tokens.
+This may also be specified on a per-host basis in the configuration file.
.It Fl l Ar login_name
Specifies the user to log in as on the remote machine.
This also may be specified on a per-host basis in the configuration file.
@@ -390,7 +390,7 @@ Causes all warning and diagnostic messages to be suppressed.
Only fatal errors are displayed.
.It Fl t
Force pseudo-tty allocation.
-This can be used to execute arbitary
+This can be used to execute arbitrary
screen-based programs on a remote machine, which can be very useful,
e.g., when implementing menu services.
.It Fl v
@@ -514,8 +514,8 @@ The host is the
argument given on the command line (i.e., the name is not converted to
a canonicalized host name before matching).
.It Cm AFSTokenPassing
-Specifies whether to pass AFS tokens to remote host. The argument to
-this keyword must be
+Specifies whether to pass AFS tokens to remote host.
+The argument to this keyword must be
.Dq yes
or
.Dq no .
@@ -534,7 +534,8 @@ If this flag is set to
.Dq yes ,
ssh will additionally check the host ip address in the
.Pa known_hosts
-file. This allows ssh to detect if a host key changed due to DNS spoofing.
+file.
+This allows ssh to detect if a host key changed due to DNS spoofing.
If the option is set to
.Dq no ,
the check will not be executed.
@@ -645,7 +646,7 @@ If they are sent, death of the connection or crash of one
of the machines will be properly noticed.
However, this means that
connections will die if the route is down temporarily, and some people
-find it annoying.
+find it annoying.
.Pp
The default is
.Dq yes
@@ -657,15 +658,15 @@ To disable keepalives, the value should be set to
.Dq no
in both the server and the client configuration files.
.It Cm KerberosAuthentication
-Specifies whether Kerberos authentication will be used. The argument to
-this keyword must be
+Specifies whether Kerberos authentication will be used.
+The argument to this keyword must be
.Dq yes
or
.Dq no .
.It Cm KerberosTgtPassing
-Specifies whether a Kerberos TGT will be forwarded to the server. This
-will only work if the Kerberos server is actually an AFS kaserver. The
-argument to this keyword must be
+Specifies whether a Kerberos TGT will be forwarded to the server.
+This will only work if the Kerberos server is actually an AFS kaserver.
+The argument to this keyword must be
.Dq yes
or
.Dq no .
@@ -684,8 +685,9 @@ The possible values are:
QUIET, FATAL, ERROR, INFO, VERBOSE and DEBUG.
The default is INFO.
.It Cm NumberOfPasswordPrompts
-Specifies the number of password prompts before giving up. The
-argument to this keyword must be an integer. Default is 3.
+Specifies the number of password prompts before giving up.
+The argument to this keyword must be an integer.
+Default is 3.
.It Cm PasswordAuthentication
Specifies whether to use password authentication.
The argument to this keyword must be
diff --git a/ssh.c b/ssh.c
index bada8e18..faba54ec 100644
--- a/ssh.c
+++ b/ssh.c
@@ -11,7 +11,7 @@
*/
#include "includes.h"
-RCSID("$Id: ssh.c,v 1.21 2000/03/09 10:27:52 damien Exp $");
+RCSID("$Id: ssh.c,v 1.22 2000/03/26 03:04:54 damien Exp $");
#include "xmalloc.h"
#include "ssh.h"
@@ -181,6 +181,7 @@ main(int ac, char **av)
struct stat st;
struct passwd *pw, pwcopy;
int interactive = 0, dummy;
+ int have_pty = 0;
uid_t original_effective_uid;
int plen;
@@ -618,9 +619,6 @@ main(int ac, char **av)
if (host_private_key_loaded)
RSA_free(host_private_key); /* Destroys contents safely */
- /* Close connection cleanly after attack. */
- cipher_attack_detected = packet_disconnect;
-
/* Enable compression if requested. */
if (options.compression) {
debug("Requesting compression at level %d.", options.compression_level);
@@ -672,9 +670,10 @@ main(int ac, char **av)
/* Read response from the server. */
type = packet_read(&plen);
- if (type == SSH_SMSG_SUCCESS)
+ if (type == SSH_SMSG_SUCCESS) {
interactive = 1;
- else if (type == SSH_SMSG_FAILURE)
+ have_pty = 1;
+ } else if (type == SSH_SMSG_FAILURE)
log("Warning: Remote host failed or refused to allocate a pseudo tty.");
else
packet_disconnect("Protocol error waiting for pty request response.");
@@ -802,7 +801,7 @@ main(int ac, char **av)
}
/* Enter the interactive session. */
- exit_status = client_loop(tty_flag, tty_flag ? options.escape_char : -1);
+ exit_status = client_loop(have_pty, tty_flag ? options.escape_char : -1);
/* Close the connection to the remote host. */
packet_close();
diff --git a/ssh.h b/ssh.h
index ee6e3c1f..8bd70815 100644
--- a/ssh.h
+++ b/ssh.h
@@ -13,7 +13,7 @@
*
*/
-/* RCSID("$Id: ssh.h,v 1.27 2000/03/09 10:27:52 damien Exp $"); */
+/* RCSID("$Id: ssh.h,v 1.28 2000/03/26 03:04:54 damien Exp $"); */
#ifndef SSH_H
#define SSH_H
@@ -338,8 +338,7 @@ int auth_rhosts(struct passwd * pw, const char *client_user);
* its host key. Returns true if authentication succeeds.
*/
int
-auth_rhosts_rsa(struct passwd * pw, const char *client_user,
- BIGNUM * client_host_key_e, BIGNUM * client_host_key_n);
+auth_rhosts_rsa(struct passwd * pw, const char *client_user, RSA* client_host_key);
/*
* Tries to authenticate the user using password. Returns true if
@@ -388,40 +387,11 @@ int get_local_port(void);
/*
- * Tries to match the host name (which must be in all lowercase) against the
- * comma-separated sequence of subpatterns (each possibly preceded by ! to
- * indicate negation). Returns true if there is a positive match; zero
- * otherwise.
- */
-int match_hostname(const char *host, const char *pattern, unsigned int len);
-
-/*
- * Checks whether the given host is already in the list of our known hosts.
- * Returns HOST_OK if the host is known and has the specified key, HOST_NEW
- * if the host is not known, and HOST_CHANGED if the host is known but used
- * to have a different host key. The host must be in all lowercase.
- */
-typedef enum {
- HOST_OK, HOST_NEW, HOST_CHANGED
-} HostStatus;
-HostStatus
-check_host_in_hostfile(const char *filename, const char *host,
- BIGNUM * e, BIGNUM * n, BIGNUM * ke, BIGNUM * kn);
-
-/*
- * Appends an entry to the host file. Returns false if the entry could not
- * be appended.
- */
-int
-add_host_to_hostfile(const char *filename, const char *host,
- BIGNUM * e, BIGNUM * n);
-
-/*
* Performs the RSA authentication challenge-response dialog with the client,
* and returns true (non-zero) if the client gave the correct answer to our
* challenge; returns zero if the client gives a wrong answer.
*/
-int auth_rsa_challenge_dialog(BIGNUM * e, BIGNUM * n);
+int auth_rsa_challenge_dialog(RSA *pk);
/*
* Reads a passphrase from /dev/tty with echo turned off. Returns the
diff --git a/sshconnect.c b/sshconnect.c
index 910548fa..d64c0e2c 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -8,15 +8,19 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshconnect.c,v 1.57 2000/03/16 20:56:14 markus Exp $");
+RCSID("$OpenBSD: sshconnect.c,v 1.58 2000/03/23 22:15:33 markus Exp $");
#ifdef HAVE_OPENSSL
-#include <openssl/bn.h>
+#include <openssl/rsa.h>
+#include <openssl/dsa.h>
#include <openssl/md5.h>
+#include <openssl/bn.h>
#endif
#ifdef HAVE_SSL
-#include <ssl/bn.h>
+#include <ssl/rsa.h>
+#include <ssl/dsa.h>
#include <ssl/md5.h>
+#include <ssl/bn.h>
#endif
#include "xmalloc.h"
@@ -29,7 +33,8 @@ RCSID("$OpenBSD: sshconnect.c,v 1.57 2000/03/16 20:56:14 markus Exp $");
#include "uidswap.h"
#include "compat.h"
#include "readconf.h"
-#include "fingerprint.h"
+#include "key.h"
+#include "hostfile.h"
/* Session id for the current session. */
unsigned char session_id[16];
@@ -1073,9 +1078,9 @@ read_yes_or_no(const char *prompt, int defval)
*/
void
-check_host_key(char *host, struct sockaddr *hostaddr, RSA *host_key)
+check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key)
{
- RSA *file_key;
+ Key *file_key;
char *ip = NULL;
char hostline[1000], *hostp;
HostStatus host_status;
@@ -1129,47 +1134,34 @@ check_host_key(char *host, struct sockaddr *hostaddr, RSA *host_key)
* Store the host key from the known host file in here so that we can
* compare it with the key for the IP address.
*/
- file_key = RSA_new();
- file_key->n = BN_new();
- file_key->e = BN_new();
+ file_key = key_new(host_key->type);
/*
* Check if the host key is present in the user\'s list of known
* hosts or in the systemwide list.
*/
- host_status = check_host_in_hostfile(options.user_hostfile, host,
- host_key->e, host_key->n,
- file_key->e, file_key->n);
+ host_status = check_host_in_hostfile(options.user_hostfile, host, host_key, file_key);
if (host_status == HOST_NEW)
- host_status = check_host_in_hostfile(options.system_hostfile, host,
- host_key->e, host_key->n,
- file_key->e, file_key->n);
+ host_status = check_host_in_hostfile(options.system_hostfile, host, host_key, file_key);
/*
* Also perform check for the ip address, skip the check if we are
* localhost or the hostname was an ip address to begin with
*/
if (options.check_host_ip && !local && strcmp(host, ip)) {
- RSA *ip_key = RSA_new();
- ip_key->n = BN_new();
- ip_key->e = BN_new();
- ip_status = check_host_in_hostfile(options.user_hostfile, ip,
- host_key->e, host_key->n,
- ip_key->e, ip_key->n);
+ Key *ip_key = key_new(host_key->type);
+ ip_status = check_host_in_hostfile(options.user_hostfile, ip, host_key, ip_key);
if (ip_status == HOST_NEW)
- ip_status = check_host_in_hostfile(options.system_hostfile, ip,
- host_key->e, host_key->n,
- ip_key->e, ip_key->n);
+ ip_status = check_host_in_hostfile(options.system_hostfile, ip, host_key, ip_key);
if (host_status == HOST_CHANGED &&
- (ip_status != HOST_CHANGED ||
- (BN_cmp(ip_key->e, file_key->e) || BN_cmp(ip_key->n, file_key->n))))
+ (ip_status != HOST_CHANGED || !key_equal(ip_key, file_key)))
host_ip_differ = 1;
- RSA_free(ip_key);
+ key_free(ip_key);
} else
ip_status = host_status;
- RSA_free(file_key);
+ key_free(file_key);
switch (host_status) {
case HOST_OK:
@@ -1177,8 +1169,7 @@ check_host_key(char *host, struct sockaddr *hostaddr, RSA *host_key)
debug("Host '%.200s' is known and matches the host key.", host);
if (options.check_host_ip) {
if (ip_status == HOST_NEW) {
- if (!add_host_to_hostfile(options.user_hostfile, ip,
- host_key->e, host_key->n))
+ if (!add_host_to_hostfile(options.user_hostfile, ip, host_key))
log("Failed to add the host key for IP address '%.30s' to the list of known hosts (%.30s).",
ip, options.user_hostfile);
else
@@ -1198,12 +1189,12 @@ check_host_key(char *host, struct sockaddr *hostaddr, RSA *host_key)
} else if (options.strict_host_key_checking == 2) {
/* The default */
char prompt[1024];
- char *fp = fingerprint(host_key->e, host_key->n);
+ char *fp = key_fingerprint(host_key);
snprintf(prompt, sizeof(prompt),
"The authenticity of host '%.200s' can't be established.\n"
- "Key fingerprint is %d %s.\n"
+ "Key fingerprint is %s.\n"
"Are you sure you want to continue connecting (yes/no)? ",
- host, BN_num_bits(host_key->n), fp);
+ host, fp);
if (!read_yes_or_no(prompt, -1))
fatal("Aborted by user!\n");
}
@@ -1214,8 +1205,7 @@ check_host_key(char *host, struct sockaddr *hostaddr, RSA *host_key)
hostp = host;
/* If not in strict mode, add the key automatically to the local known_hosts file. */
- if (!add_host_to_hostfile(options.user_hostfile, hostp,
- host_key->e, host_key->n))
+ if (!add_host_to_hostfile(options.user_hostfile, hostp, host_key))
log("Failed to add the host to the list of known hosts (%.500s).",
options.user_hostfile);
else
@@ -1283,6 +1273,14 @@ check_host_key(char *host, struct sockaddr *hostaddr, RSA *host_key)
if (options.check_host_ip)
xfree(ip);
}
+void
+check_rsa_host_key(char *host, struct sockaddr *hostaddr, RSA *host_key)
+{
+ Key k;
+ k.type = KEY_RSA;
+ k.rsa = host_key;
+ check_host_key(host, hostaddr, &k);
+}
/*
* SSH1 key exchange
@@ -1358,7 +1356,7 @@ ssh_kex(char *host, struct sockaddr *hostaddr)
8 + 4 + sum_len + 0 + 4 + 0 + 0 + 4 + 4 + 4,
SSH_SMSG_PUBLIC_KEY);
- check_host_key(host, hostaddr, host_key);
+ check_rsa_host_key(host, hostaddr, host_key);
client_flags = SSH_PROTOFLAG_SCREEN_NUMBER | SSH_PROTOFLAG_HOST_IN_FWD_OPEN;
@@ -1617,7 +1615,6 @@ ssh_userauth(int host_key_valid, RSA *own_host_key,
fatal("Permission denied.");
/* NOTREACHED */
}
-
/*
* Starts a dialog with the server, and authenticates the current user on the
* server. This does not need any extra privileges. The basic connection
@@ -1648,6 +1645,7 @@ ssh_login(int host_key_valid, RSA *own_host_key, const char *orighost,
ssh_kex(host, hostaddr);
if (supported_authentications == 0)
fatal("supported_authentications == 0.");
+
/* authenticate user */
ssh_userauth(host_key_valid, own_host_key, original_real_uid, host);
}
diff --git a/sshd.8 b/sshd.8
index a2049018..3c24210b 100644
--- a/sshd.8
+++ b/sshd.8
@@ -9,7 +9,7 @@
.\"
.\" Created: Sat Apr 22 21:55:14 1995 ylo
.\"
-.\" $Id: sshd.8,v 1.14 2000/03/17 12:40:18 damien Exp $
+.\" $Id: sshd.8,v 1.15 2000/03/26 03:04:55 damien Exp $
.\"
.Dd September 25, 1999
.Dt SSHD 8
@@ -33,39 +33,48 @@
.Xr ssh 1 .
Together these programs replace rlogin and rsh programs, and
provide secure encrypted communications between two untrusted hosts
-over an insecure network. The programs are intended to be as easy to
+over an insecure network.
+The programs are intended to be as easy to
install and use as possible.
.Pp
.Nm
-is the daemon that listens for connections from clients. It is
-normally started at boot from
+is the daemon that listens for connections from clients.
+It is normally started at boot from
.Pa /etc/rc .
It forks a new
-daemon for each incoming connection. The forked daemons handle
+daemon for each incoming connection.
+The forked daemons handle
key exchange, encryption, authentication, command execution,
and data exchange.
.Pp
.Nm
-works as follows. Each host has a host-specific RSA key
-(normally 1024 bits) used to identify the host. Additionally, when
+works as follows.
+Each host has a host-specific RSA key
+(normally 1024 bits) used to identify the host.
+Additionally, when
the daemon starts, it generates a server RSA key (normally 768 bits).
This key is normally regenerated every hour if it has been used, and
is never stored on disk.
.Pp
Whenever a client connects the daemon, the daemon sends its host
-and server public keys to the client. The client compares the
+and server public keys to the client.
+The client compares the
host key against its own database to verify that it has not changed.
-The client then generates a 256 bit random number. It encrypts this
+The client then generates a 256 bit random number.
+It encrypts this
random number using both the host key and the server key, and sends
-the encrypted number to the server. Both sides then start to use this
+the encrypted number to the server.
+Both sides then start to use this
random number as a session key which is used to encrypt all further
-communications in the session. The rest of the session is encrypted
+communications in the session.
+The rest of the session is encrypted
using a conventional cipher, currently Blowfish and 3DES, with 3DES
-being is used by default. The client selects the encryption algorithm
+being is used by default.
+The client selects the encryption algorithm
to use from those offered by the server.
.Pp
-Next, the server and the client enter an authentication dialog. The
-client tries to authenticate itself using
+Next, the server and the client enter an authentication dialog.
+The client tries to authenticate itself using
.Pa .rhosts
authentication,
.Pa .rhosts
@@ -75,7 +84,8 @@ based authentication.
.Pp
Rhosts authentication is normally disabled
because it is fundamentally insecure, but can be enabled in the server
-configuration file if desired. System security is not improved unless
+configuration file if desired.
+System security is not improved unless
.Xr rshd 8 ,
.Xr rlogind 8 ,
.Xr rexecd 8 ,
@@ -88,13 +98,15 @@ and
into that machine).
.Pp
If the client successfully authenticates itself, a dialog for
-preparing the session is entered. At this time the client may request
+preparing the session is entered.
+At this time the client may request
things like allocating a pseudo-tty, forwarding X11 connections,
forwarding TCP/IP connections, or forwarding the authentication agent
connection over the secure channel.
.Pp
Finally, the client either requests a shell or execution of a command.
-The sides then enter session mode. In this mode, either side may send
+The sides then enter session mode.
+In this mode, either side may send
data at any time, and such data is forwarded to/from the shell or
command on the server side, and the user terminal in the client side.
.Pp
@@ -104,7 +116,8 @@ the client, and both sides exit.
.Pp
.Nm
can be configured using command-line options or a configuration
-file. Command-line options override values specified in the
+file.
+Command-line options override values specified in the
configuration file.
.Pp
.Nm
@@ -117,20 +130,23 @@ The options are as follows:
Specifies the number of bits in the server key (default 768).
.Pp
.It Fl d
-Debug mode. The server sends verbose debug output to the system
-log, and does not put itself in the background. The server also will
-not fork and will only process one connection. This option is only
-intended for debugging for the server.
+Debug mode.
+The server sends verbose debug output to the system
+log, and does not put itself in the background.
+The server also will not fork and will only process one connection.
+This option is only intended for debugging for the server.
.It Fl f Ar configuration_file
-Specifies the name of the configuration file. The default is
+Specifies the name of the configuration file.
+The default is
.Pa /etc/sshd_config .
.Nm
refuses to start if there is no configuration file.
.It Fl g Ar login_grace_time
Gives the grace time for clients to authenticate themselves (default
-300 seconds). If the client fails to authenticate the user within
-this many seconds, the server disconnects and exits. A value of zero
-indicates no limit.
+300 seconds).
+If the client fails to authenticate the user within
+this many seconds, the server disconnects and exits.
+A value of zero indicates no limit.
.It Fl h Ar host_key_file
Specifies the file from which the host key is read (default
.Pa /etc/ssh_host_key ) .
@@ -145,24 +161,28 @@ is being run from inetd.
.Nm
is normally not run
from inetd because it needs to generate the server key before it can
-respond to the client, and this may take tens of seconds. Clients
-would have to wait too long if the key was regenerated every time.
+respond to the client, and this may take tens of seconds.
+Clients would have to wait too long if the key was regenerated every time.
However, with small key sizes (e.g., 512) using
.Nm
from inetd may
be feasible.
.It Fl k Ar key_gen_time
Specifies how often the server key is regenerated (default 3600
-seconds, or one hour). The motivation for regenerating the key fairly
+seconds, or one hour).
+The motivation for regenerating the key fairly
often is that the key is not stored anywhere, and after about an hour,
it becomes impossible to recover the key for decrypting intercepted
communications even if the machine is cracked into or physically
-seized. A value of zero indicates that the key will never be regenerated.
+seized.
+A value of zero indicates that the key will never be regenerated.
.It Fl p Ar port
Specifies the port on which the server listens for connections
(default 22).
.It Fl q
-Quiet mode. Nothing is sent to the system log. Normally the beginning,
+Quiet mode.
+Nothing is sent to the system log.
+Normally the beginning,
authentication, and termination of each connection is logged.
.It Fl Q
Do not print an error message if RSA support is missing.
@@ -188,39 +208,43 @@ reads configuration data from
.Pa /etc/sshd_config
(or the file specified with
.Fl f
-on the command line). The file
-contains keyword-value pairs, one per line. Lines starting with
+on the command line).
+The file contains keyword-value pairs, one per line.
+Lines starting with
.Ql #
and empty lines are interpreted as comments.
.Pp
The following keywords are possible.
.Bl -tag -width Ds
.It Cm AFSTokenPassing
-Specifies whether an AFS token may be forwarded to the server. Default is
+Specifies whether an AFS token may be forwarded to the server.
+Default is
.Dq yes .
.It Cm AllowGroups
This keyword can be followed by a number of group names, separated
-by spaces. If specified, login is allowed only for users whose primary
+by spaces.
+If specified, login is allowed only for users whose primary
group matches one of the patterns.
.Ql \&*
and
.Ql ?
can be used as
-wildcards in the patterns. Only group names are valid, a numerical group
-id isn't recognized. By default login is allowed regardless of
-the primary group.
+wildcards in the patterns.
+Only group names are valid, a numerical group ID isn't recognized.
+By default login is allowed regardless of the primary group.
.Pp
.It Cm AllowUsers
This keyword can be followed by a number of user names, separated
-by spaces. If specified, login is allowed only for users names that
+by spaces.
+If specified, login is allowed only for users names that
match one of the patterns.
.Ql \&*
and
.Ql ?
can be used as
-wildcards in the patterns. Only user names are valid, a numerical user
-id isn't recognized. By default login is allowed regardless of
-the user name.
+wildcards in the patterns.
+Only user names are valid, a numerical user ID isn't recognized.
+By default login is allowed regardless of the user name.
.Pp
.It Cm CheckMail
Specifies whether
@@ -230,27 +254,27 @@ The default is
.Dq no .
.It Cm DenyGroups
This keyword can be followed by a number of group names, separated
-by spaces. Users whose primary group matches one of the patterns
+by spaces.
+Users whose primary group matches one of the patterns
aren't allowed to log in.
.Ql \&*
and
.Ql ?
can be used as
-wildcards in the patterns. Only group names are valid, a numerical group
-id isn't recognized. By default login is allowed regardless of
-the primary group.
+wildcards in the patterns.
+Only group names are valid, a numerical group ID isn't recognized.
+By default login is allowed regardless of the primary group.
.Pp
.It Cm DenyUsers
This keyword can be followed by a number of user names, separated
-by spaces. Login is disallowed for user names that match
-one of the patterns.
+by spaces.
+Login is disallowed for user names that match one of the patterns.
.Ql \&*
and
.Ql ?
-can be used as
-wildcards in the patterns. Only user names are valid, a numerical user
-id isn't recognized. By default login is allowed regardless of
-the user name.
+can be used as wildcards in the patterns.
+Only user names are valid, a numerical user ID isn't recognized.
+By default login is allowed regardless of the user name.
.It Cm HostKey
Specifies the file containing the private host key (default
.Pa /etc/ssh_host_key ) .
@@ -266,7 +290,8 @@ files will not be used in authentication.
.Pa /etc/hosts.equiv
and
.Pa /etc/shosts.equiv
-are still used. The default is
+are still used.
+The default is
.Dq yes .
.It Cm IgnoreUserKnownHosts
Specifies whether
@@ -279,10 +304,13 @@ The default is
.Dq no .
.It Cm KeepAlive
Specifies whether the system should send keepalive messages to the
-other side. If they are sent, death of the connection or crash of one
-of the machines will be properly noticed. However, this means that
+other side.
+If they are sent, death of the connection or crash of one
+of the machines will be properly noticed.
+However, this means that
connections will die if the route is down temporarily, and some people
-find it annoying. On the other hand, if keepalives are not send,
+find it annoying.
+On the other hand, if keepalives are not send,
sessions may hang indefinitely on the server, leaving
.Dq ghost
users and consuming server resources.
@@ -290,25 +318,27 @@ users and consuming server resources.
The default is
.Dq yes
(to send keepalives), and the server will notice
-if the network goes down or the client host reboots. This avoids
-infinitely hanging sessions.
+if the network goes down or the client host reboots.
+This avoids infinitely hanging sessions.
.Pp
To disable keepalives, the value should be set to
.Dq no
in both the server and the client configuration files.
.It Cm KerberosAuthentication
-Specifies whether Kerberos authentication is allowed. This can
-be in the form of a Kerberos ticket, or if
+Specifies whether Kerberos authentication is allowed.
+This can be in the form of a Kerberos ticket, or if
.Cm PasswordAuthentication
is yes, the password provided by the user will be validated through
-the Kerberos KDC. Default is
+the Kerberos KDC.
+Default is
.Dq yes .
.It Cm KerberosOrLocalPasswd
If set then if password authentication through Kerberos fails then
the password will be validated via any additional local mechanism
such as
.Pa /etc/passwd
-or SecurID. Default is
+or SecurID.
+Default is
.Dq yes .
.It Cm KerberosTgtPassing
Specifies whether a Kerberos TGT may be forwarded to the server.
@@ -317,15 +347,18 @@ Default is
as this only works when the Kerberos KDC is actually an AFS kaserver.
.It Cm KerberosTicketCleanup
Specifies whether to automatically destroy the user's ticket cache
-file on logout. Default is
+file on logout.
+Default is
.Dq yes .
.It Cm KeyRegenerationInterval
The server key is automatically regenerated after this many seconds
-(if it has been used). The purpose of regeneration is to prevent
+(if it has been used).
+The purpose of regeneration is to prevent
decrypting captured sessions by later breaking into the machine and
-stealing the keys. The key is never stored anywhere. If the value is
-0, the key is never regenerated. The default is 3600
-(seconds).
+stealing the keys.
+The key is never stored anywhere.
+If the value is 0, the key is never regenerated.
+The default is 3600 (seconds).
.It Cm ListenAddress
Specifies what local address
.Nm
@@ -337,7 +370,8 @@ Additionally, the
options must precede this option.
.It Cm LoginGraceTime
The server disconnects after this time if the user has not
-successfully logged in. If the value is 0, there is no time limit.
+successfully logged in.
+If the value is 0, there is no time limit.
The default is 600 (seconds).
.It Cm LogLevel
Gives the verbosity level that is used when logging messages from
@@ -353,8 +387,8 @@ The default is
.Dq yes .
.It Cm PermitEmptyPasswords
When password authentication is allowed, it specifies whether the
-server allows login to accounts with empty password strings. The default
-is
+server allows login to accounts with empty password strings.
+The default is
.Dq no .
.It Cm PermitRootLogin
Specifies whether the root can log in using
@@ -379,24 +413,27 @@ normally not allowed).
.It Cm Port
Specifies the port number that
.Nm
-listens on. The default is 22.
+listens on.
+The default is 22.
Multiple options of this type are permitted.
.It Cm PrintMotd
Specifies whether
.Nm
should print
.Pa /etc/motd
-when a user logs in interactively. (On some systems it is also
-printed by the shell,
+when a user logs in interactively.
+(On some systems it is also printed by the shell,
.Pa /etc/profile ,
-or equivalent.) The default is
+or equivalent.)
+The default is
.Dq yes .
.It Cm RandomSeed
-Obsolete. Random number generation uses other techniques.
+Obsolete.
+Random number generation uses other techniques.
.It Cm RhostsAuthentication
Specifies whether authentication using rhosts or /etc/hosts.equiv
-files is sufficient. Normally, this method should not be permitted
-because it is insecure.
+files is sufficient.
+Normally, this method should not be permitted because it is insecure.
.Cm RhostsRSAAuthentication
should be used
instead, because it performs RSA-based host authentication in addition
@@ -405,18 +442,21 @@ The default is
.Dq no .
.It Cm RhostsRSAAuthentication
Specifies whether rhosts or /etc/hosts.equiv authentication together
-with successful RSA host authentication is allowed. The default is
+with successful RSA host authentication is allowed.
+The default is
.Dq no .
.It Cm RSAAuthentication
-Specifies whether pure RSA authentication is allowed. The default is
+Specifies whether pure RSA authentication is allowed.
+The default is
.Dq yes .
.It Cm ServerKeyBits
-Defines the number of bits in the server key. The minimum value is
-512, and the default is 768.
+Defines the number of bits in the server key.
+The minimum value is 512, and the default is 768.
.It Cm SkeyAuthentication
Specifies whether
.Xr skey 1
-authentication is allowed. The default is
+authentication is allowed.
+The default is
.Dq yes .
Note that s/key authentication is enabled only if
.Cm PasswordAuthentication
@@ -425,29 +465,34 @@ is allowed, too.
Specifies whether
.Nm
should check file modes and ownership of the
-user's files and home directory before accepting login. This
-is normally desirable because novices sometimes accidentally leave their
-directory or files world-writable. The default is
+user's files and home directory before accepting login.
+This is normally desirable because novices sometimes accidentally leave their
+directory or files world-writable.
+The default is
.Dq yes .
.It Cm SyslogFacility
Gives the facility code that is used when logging messages from
.Nm sshd .
The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2,
-LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7. The default is AUTH.
+LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
+The default is AUTH.
.It Cm UseLogin
Specifies whether
.Xr login 1
-is used. The default is
+is used.
+The default is
.Dq no .
.It Cm X11DisplayOffset
Specifies the first display number available for
.Nm sshd Ns 's
-X11 forwarding. This prevents
+X11 forwarding.
+This prevents
.Nm
from interfering with real X11 servers.
The default is 10.
.It Cm X11Forwarding
-Specifies whether X11 forwarding is permitted. The default is
+Specifies whether X11 forwarding is permitted.
+The default is
.Dq no .
Note that disabling X11 forwarding does not improve security in any
way, as users can always install their own forwarders.
@@ -489,7 +534,8 @@ If
exists, runs it; else if
.Pa /etc/sshrc
exists, runs
-it; otherwise runs xauth. The
+it; otherwise runs xauth.
+The
.Dq rc
files are given the X11
authentication protocol and cookie in standard input.
@@ -500,12 +546,15 @@ Runs user's shell or command.
The
.Pa $HOME/.ssh/authorized_keys
file lists the RSA keys that are
-permitted for RSA authentication. Each line of the file contains one
+permitted for RSA authentication.
+Each line of the file contains one
key (empty lines and lines starting with a
.Ql #
are ignored as
-comments). Each line consists of the following fields, separated by
-spaces: options, bits, exponent, modulus, comment. The options field
+comments).
+Each line consists of the following fields, separated by
+spaces: options, bits, exponent, modulus, comment.
+The options field
is optional; its presence is determined by whether the line starts
with a number or not (the option field never starts with a number).
The bits, exponent, modulus and comment fields give the RSA key; the
@@ -513,47 +562,58 @@ comment field is not used for anything (but may be convenient for the
user to identify the key).
.Pp
Note that lines in this file are usually several hundred bytes long
-(because of the size of the RSA key modulus). You don't want to type
-them in; instead, copy the
+(because of the size of the RSA key modulus).
+You don't want to type them in; instead, copy the
.Pa identity.pub
file and edit it.
.Pp
The options (if present) consists of comma-separated option
-specifications. No spaces are permitted, except within double quotes.
+specifications.
+No spaces are permitted, except within double quotes.
The following option specifications are supported:
.Bl -tag -width Ds
.It Cm from="pattern-list"
Specifies that in addition to RSA authentication, the canonical name
of the remote host must be present in the comma-separated list of
-patterns ('*' and '?' serve as wildcards). The list may also contain
-patterns negated by prefixing them with '!'; if the canonical host
-name matches a negated pattern, the key is not accepted. The purpose
+patterns
+.Pf ( Ql *
+and
+.Ql ?
+serve as wildcards).
+The list may also contain
+patterns negated by prefixing them with
+.Ql ! ;
+if the canonical host name matches a negated pattern, the key is not accepted.
+The purpose
of this option is to optionally increase security: RSA authentication
by itself does not trust the network or name servers or anything (but
the key); however, if somebody somehow steals the key, the key
-permits an intruder to log in from anywhere in the world. This
-additional option makes using a stolen key more difficult (name
+permits an intruder to log in from anywhere in the world.
+This additional option makes using a stolen key more difficult (name
servers and/or routers would have to be compromised in addition to
just the key).
.It Cm command="command"
Specifies that the command is executed whenever this key is used for
-authentication. The command supplied by the user (if any) is ignored.
+authentication.
+The command supplied by the user (if any) is ignored.
The command is run on a pty if the connection requests a pty;
-otherwise it is run without a tty. A quote may be included in the
-command by quoting it with a backslash. This option might be useful
-to restrict certain RSA keys to perform just a specific operation. An
-example might be a key that permits remote backups but nothing
-else. Notice that the client may specify TCP/IP and/or X11
+otherwise it is run without a tty.
+A quote may be included in the command by quoting it with a backslash.
+This option might be useful
+to restrict certain RSA keys to perform just a specific operation.
+An example might be a key that permits remote backups but nothing else.
+Notice that the client may specify TCP/IP and/or X11
forwardings unless they are explicitly prohibited.
.It Cm environment="NAME=value"
Specifies that the string is to be added to the environment when
-logging in using this key. Environment variables set this way
-override other default environment values. Multiple options of this
-type are permitted.
+logging in using this key.
+Environment variables set this way
+override other default environment values.
+Multiple options of this type are permitted.
.It Cm no-port-forwarding
Forbids TCP/IP forwarding when this key is used for authentication.
-Any port forward requests by the client will return an error. This
-might be used, e.g., in connection with the
+Any port forward requests by the client will return an error.
+This might be used, e.g., in connection with the
.Cm command
option.
.It Cm no-X11-forwarding
@@ -576,19 +636,21 @@ The
.Pa /etc/ssh_known_hosts
and
.Pa $HOME/.ssh/known_hosts
-files contain host public keys for all known hosts. The global file should
-be prepared by the admistrator (optional), and the per-user file is
+files contain host public keys for all known hosts.
+The global file should
+be prepared by the administrator (optional), and the per-user file is
maintained automatically: whenever the user connects an unknown host
-its key is added to the per-user file.
+its key is added to the per-user file.
.Pp
Each line in these files contains the following fields: hostnames,
-bits, exponent, modulus, comment. The fields are separated by spaces.
+bits, exponent, modulus, comment.
+The fields are separated by spaces.
.Pp
Hostnames is a comma-separated list of patterns ('*' and '?' act as
wildcards); each pattern in turn is matched against the canonical host
name (when authenticating a client) or against the user-supplied
-name (when authenticating a server). A pattern may also be preceded
-by
+name (when authenticating a server).
+A pattern may also be preceded by
.Ql !
to indicate negation: if the host name matches a negated
pattern, it is not accepted (by that line) even if it matched another
@@ -604,10 +666,13 @@ Lines starting with
and empty lines are ignored as comments.
.Pp
When performing host authentication, authentication is accepted if any
-matching line has the proper key. It is thus permissible (but not
+matching line has the proper key.
+It is thus permissible (but not
recommended) to have several lines or different host keys for the same
-names. This will inevitably happen when short forms of host names
-from different domains are put in the file. It is possible
+names.
+This will inevitably happen when short forms of host names
+from different domains are put in the file.
+It is possible
that the files contain conflicting information; authentication is
accepted if valid information can be found from either file.
.Pp
@@ -636,7 +701,9 @@ does not start if this file is group/world-accessible.
.It Pa /etc/ssh_host_key.pub
Contains the public part of the host key.
This file should be world-readable but writable only by
-root. Its contents should match the private part. This file is not
+root.
+Its contents should match the private part.
+This file is not
really used for anything; it is only provided for the convenience of
the user so its contents can be copied to known hosts files.
These two files are created using
@@ -646,21 +713,22 @@ Contains the process ID of the
.Nm
listening for connections (if there are several daemons running
concurrently for different ports, this contains the pid of the one
-started last). The contents of this file are not sensitive; it can be
-world-readable.
+started last).
+The contents of this file are not sensitive; it can be world-readable.
.It Pa $HOME/.ssh/authorized_keys
Lists the RSA keys that can be used to log into the user's account.
This file must be readable by root (which may on some machines imply
it being world-readable if the user's home directory resides on an NFS
-volume). It is recommended that it not be accessible by others. The
-format of this file is described above.
+volume).
+It is recommended that it not be accessible by others.
+The format of this file is described above.
.It Pa "/etc/ssh_known_hosts" and "$HOME/.ssh/known_hosts"
These files are consulted when using rhosts with RSA host
-authentication to check the public key of the host. The key must be
-listed in one of these files to be accepted.
+authentication to check the public key of the host.
+The key must be listed in one of these files to be accepted.
The client uses the same files
-to verify that the remote host is the one we intended to
-connect. These files should be writable only by root/the owner.
+to verify that the remote host is the one we intended to connect.
+These files should be writable only by root/the owner.
.Pa /etc/ssh_known_hosts
should be world-readable, and
.Pa $HOME/.ssh/known_hosts
@@ -668,9 +736,11 @@ can but need not be world-readable.
.It Pa /etc/nologin
If this file exists,
.Nm
-refuses to let anyone except root log in. The contents of the file
+refuses to let anyone except root log in.
+The contents of the file
are displayed to anyone trying to log in, and non-root connections are
-refused. The file should be world-readable.
+refused.
+The file should be world-readable.
.It Pa /etc/hosts.allow, /etc/hosts.deny
If compiled with
.Sy LIBWRAP
@@ -678,13 +748,16 @@ support, tcp-wrappers access controls may be defined here as described in
.Xr hosts_access 5 .
.It Pa $HOME/.rhosts
This file contains host-username pairs, separated by a space, one per
-line. The given user on the corresponding host is permitted to log in
-without password. The same file is used by rlogind and rshd.
+line.
+The given user on the corresponding host is permitted to log in
+without password.
+The same file is used by rlogind and rshd.
The file must
be writable only by the user; it is recommended that it not be
accessible by others.
.Pp
-If is also possible to use netgroups in the file. Either host or user
+If is also possible to use netgroups in the file.
+Either host or user
name may be of the form +@groupname to specify all hosts or all users
in the group.
.It Pa $HOME/.shosts
@@ -696,21 +769,26 @@ not used by rlogin and rshd, so using this permits access using SSH only.
.Pa /etc/hosts.equiv
This file is used during
.Pa .rhosts
-authentication. In the
-simplest form, this file contains host names, one per line. Users on
+authentication.
+In the simplest form, this file contains host names, one per line.
+Users on
those hosts are permitted to log in without a password, provided they
-have the same user name on both machines. The host name may also be
+have the same user name on both machines.
+The host name may also be
followed by a user name; such users are permitted to log in as
.Em any
-user on this machine (except root). Additionally, the syntax
+user on this machine (except root).
+Additionally, the syntax
.Dq +@group
-can be used to specify netgroups. Negated entries start with
+can be used to specify netgroups.
+Negated entries start with
.Ql \&- .
.Pp
If the client host/user is successfully matched in this file, login is
automatically permitted provided the client and server user names are the
-same. Additionally, successful RSA host authentication is normally
-required. This file must be writable only by root; it is recommended
+same.
+Additionally, successful RSA host authentication is normally required.
+This file must be writable only by root; it is recommended
that it be world-readable.
.Pp
.Sy "Warning: It is almost never a good idea to use user names in"
@@ -718,8 +796,9 @@ that it be world-readable.
Beware that it really means that the named user(s) can log in as
.Em anybody ,
which includes bin, daemon, adm, and other accounts that own critical
-binaries and directories. Using a user name practically grants the
-user root access. The only valid use for user names that I can think
+binaries and directories.
+Using a user name practically grants the user root access.
+The only valid use for user names that I can think
of is in negative entries.
.Pp
Note that this warning also applies to rsh/rlogin.
@@ -729,18 +808,20 @@ This is processed exactly as
However, this file may be useful in environments that want to run both
rsh/rlogin and ssh.
.It Pa $HOME/.ssh/environment
-This file is read into the environment at login (if it exists). It
-can only contain empty lines, comment lines (that start with
+This file is read into the environment at login (if it exists).
+It can only contain empty lines, comment lines (that start with
.Ql # ) ,
-and assignment lines of the form name=value. The file should be writable
+and assignment lines of the form name=value.
+The file should be writable
only by the user; it need not be readable by anyone else.
.It Pa $HOME/.ssh/rc
If this file exists, it is run with /bin/sh after reading the
-environment files but before starting the user's shell or command. If
-X11 spoofing is in use, this will receive the "proto cookie" pair in
+environment files but before starting the user's shell or command.
+If X11 spoofing is in use, this will receive the "proto cookie" pair in
standard input (and
.Ev DISPLAY
-in environment). This must call
+in environment).
+This must call
.Xr xauth 1
in that case.
.Pp
@@ -763,12 +844,13 @@ readable by anyone else.
Like
.Pa $HOME/.ssh/rc .
This can be used to specify
-machine-specific login-time initializations globally. This file
-should be writable only by root, and should be world-readable.
+machine-specific login-time initializations globally.
+This file should be writable only by root, and should be world-readable.
.Sh AUTHOR
OpenSSH
is a derivative of the original (free) ssh 1.2.12 release by Tatu Ylonen,
-but with bugs removed and newer features re-added. Rapidly after the
+but with bugs removed and newer features re-added.
+Rapidly after the
1.2.12 release, newer versions of the original ssh bore successively
more restrictive licenses, and thus demand for a free version was born.
This version of OpenSSH
diff --git a/sshd.c b/sshd.c
index 98b6138a..bf951212 100644
--- a/sshd.c
+++ b/sshd.c
@@ -11,7 +11,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshd.c,v 1.92 2000/03/16 20:56:15 markus Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.94 2000/03/23 22:15:34 markus Exp $");
#include "xmalloc.h"
#include "rsa.h"
@@ -516,9 +516,6 @@ main(int ac, char **av)
unmounted if desired. */
chdir("/");
- /* Close connection cleanly after attack. */
- cipher_attack_detected = packet_disconnect;
-
/* Start listening for a socket, unless started from inetd. */
if (inetd_flag) {
int s1, s2;
@@ -1301,7 +1298,7 @@ do_authloop(struct passwd * pw)
{
int attempt = 0;
unsigned int bits;
- BIGNUM *client_host_key_e, *client_host_key_n;
+ RSA *client_host_key;
BIGNUM *n;
char *client_user = NULL, *password = NULL;
char user[1024];
@@ -1417,21 +1414,24 @@ do_authloop(struct passwd * pw)
client_user = packet_get_string(&ulen);
/* Get the client host key. */
- client_host_key_e = BN_new();
- client_host_key_n = BN_new();
+ client_host_key = RSA_new();
+ if (client_host_key == NULL)
+ fatal("RSA_new failed");
+ client_host_key->e = BN_new();
+ client_host_key->n = BN_new();
+ if (client_host_key->e == NULL || client_host_key->n == NULL)
+ fatal("BN_new failed");
bits = packet_get_int();
- packet_get_bignum(client_host_key_e, &elen);
- packet_get_bignum(client_host_key_n, &nlen);
+ packet_get_bignum(client_host_key->e, &elen);
+ packet_get_bignum(client_host_key->n, &nlen);
- if (bits != BN_num_bits(client_host_key_n))
+ if (bits != BN_num_bits(client_host_key->n))
error("Warning: keysize mismatch for client_host_key: "
- "actual %d, announced %d", BN_num_bits(client_host_key_n), bits);
+ "actual %d, announced %d", BN_num_bits(client_host_key->n), bits);
packet_integrity_check(plen, (4 + ulen) + 4 + elen + nlen, type);
- authenticated = auth_rhosts_rsa(pw, client_user,
- client_host_key_e, client_host_key_n);
- BN_clear_free(client_host_key_e);
- BN_clear_free(client_host_key_n);
+ authenticated = auth_rhosts_rsa(pw, client_user, client_host_key);
+ RSA_free(client_host_key);
snprintf(user, sizeof user, " ruser %s", client_user);
break;