aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crypto/openssh/README4
-rw-r--r--crypto/openssh/atomicio.c7
-rw-r--r--crypto/openssh/auth-krb4.c11
-rw-r--r--crypto/openssh/auth-rh-rsa.c40
-rw-r--r--crypto/openssh/auth-rsa.c37
-rw-r--r--crypto/openssh/bufaux.c8
-rw-r--r--crypto/openssh/channels.c6
-rw-r--r--crypto/openssh/cipher.c16
-rw-r--r--crypto/openssh/cipher.h8
-rw-r--r--crypto/openssh/compress.c12
-rw-r--r--crypto/openssh/fingerprint.c4
-rw-r--r--crypto/openssh/hostfile.c193
-rw-r--r--crypto/openssh/hostfile.h22
-rw-r--r--crypto/openssh/key.c290
-rw-r--r--crypto/openssh/key.h23
-rw-r--r--crypto/openssh/lib/Makefile5
-rw-r--r--crypto/openssh/log-client.c6
-rw-r--r--crypto/openssh/log-server.c8
-rw-r--r--crypto/openssh/match.c61
-rw-r--r--crypto/openssh/match.h18
-rw-r--r--crypto/openssh/packet.h6
-rw-r--r--crypto/openssh/radix.c4
-rw-r--r--crypto/openssh/readconf.c4
-rw-r--r--crypto/openssh/rsa.c6
-rw-r--r--crypto/openssh/scp.129
-rw-r--r--crypto/openssh/scp.c8
-rw-r--r--crypto/openssh/servconf.c14
-rw-r--r--crypto/openssh/ssh-add.133
-rw-r--r--crypto/openssh/ssh-agent.152
-rw-r--r--crypto/openssh/ssh-agent.c9
-rw-r--r--crypto/openssh/ssh-keygen.162
-rw-r--r--crypto/openssh/ssh-keygen.c5
-rw-r--r--crypto/openssh/ssh.1532
-rw-r--r--crypto/openssh/ssh.c14
-rw-r--r--crypto/openssh/ssh.h36
-rw-r--r--crypto/openssh/ssh/Makefile2
-rw-r--r--crypto/openssh/sshconnect.c94
-rw-r--r--crypto/openssh/sshd.8406
-rw-r--r--crypto/openssh/sshd.c74
-rw-r--r--crypto/openssh/sshd/Makefile8
-rw-r--r--crypto/openssh/version.h2
41 files changed, 1340 insertions, 839 deletions
diff --git a/crypto/openssh/README b/crypto/openssh/README
index 04c733c8ac6f..70dd61264148 100644
--- a/crypto/openssh/README
+++ b/crypto/openssh/README
@@ -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/crypto/openssh/atomicio.c b/crypto/openssh/atomicio.c
index 01c1f6285ad1..668d4900e937 100644
--- a/crypto/openssh/atomicio.c
+++ b/crypto/openssh/atomicio.c
@@ -24,7 +24,7 @@
*/
#include "includes.h"
-RCSID("$Id: atomicio.c,v 1.2 2000/02/01 22:32:53 d Exp $");
+RCSID("$Id: atomicio.c,v 1.3 2000/03/16 20:56:13 markus Exp $");
#include "xmalloc.h"
#include "ssh.h"
@@ -33,12 +33,13 @@ RCSID("$Id: atomicio.c,v 1.2 2000/02/01 22:32:53 d Exp $");
* ensure all of data on socket comes through. f==read || f==write
*/
ssize_t
-atomicio(f, fd, s, n)
+atomicio(f, fd, _s, n)
ssize_t (*f) ();
int fd;
- void *s;
+ void *_s;
size_t n;
{
+ char *s = _s;
ssize_t res, pos = 0;
while (n > pos) {
diff --git a/crypto/openssh/auth-krb4.c b/crypto/openssh/auth-krb4.c
index fb0e20ce21b8..7e30646f88db 100644
--- a/crypto/openssh/auth-krb4.c
+++ b/crypto/openssh/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;
@@ -186,19 +186,20 @@ auth_krb4(const char *server_user, KTEXT auth, char **client)
KTEXT_ST reply;
char instance[INST_SZ];
int r, s;
+ socklen_t slen;
u_int cksum;
Key_schedule schedule;
struct sockaddr_in local, foreign;
s = packet_get_connection_in();
- r = sizeof(local);
+ slen = sizeof(local);
memset(&local, 0, sizeof(local));
- if (getsockname(s, (struct sockaddr *) & local, &r) < 0)
+ if (getsockname(s, (struct sockaddr *) & local, &slen) < 0)
debug("getsockname failed: %.100s", strerror(errno));
- r = sizeof(foreign);
+ slen = sizeof(foreign);
memset(&foreign, 0, sizeof(foreign));
- if (getpeername(s, (struct sockaddr *) & foreign, &r) < 0) {
+ if (getpeername(s, (struct sockaddr *) & foreign, &slen) < 0) {
debug("getpeername failed: %.100s", strerror(errno));
fatal_cleanup();
}
diff --git a/crypto/openssh/auth-rh-rsa.c b/crypto/openssh/auth-rh-rsa.c
index a9195f0d96be..b7adab7b96be 100644
--- a/crypto/openssh/auth-rh-rsa.c
+++ b/crypto/openssh/auth-rh-rsa.c
@@ -15,7 +15,7 @@
*/
#include "includes.h"
-RCSID("$Id: auth-rh-rsa.c,v 1.10 1999/11/24 19:53:43 markus Exp $");
+RCSID("$Id: auth-rh-rsa.c,v 1.11 2000/03/23 22:15:33 markus Exp $");
#include "packet.h"
#include "ssh.h"
@@ -23,37 +23,46 @@ RCSID("$Id: auth-rh-rsa.c,v 1.10 1999/11/24 19:53:43 markus Exp $");
#include "uidswap.h"
#include "servconf.h"
+#include <ssl/rsa.h>
+#include <ssl/dsa.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 +82,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 +98,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 +109,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/crypto/openssh/auth-rsa.c b/crypto/openssh/auth-rsa.c
index a04adf67c950..3d2e84f1c06a 100644
--- a/crypto/openssh/auth-rsa.c
+++ b/crypto/openssh/auth-rsa.c
@@ -16,7 +16,7 @@
*/
#include "includes.h"
-RCSID("$Id: auth-rsa.c,v 1.18 2000/02/11 10:59:11 markus Exp $");
+RCSID("$Id: auth-rsa.c,v 1.19 2000/03/23 22:15:33 markus Exp $");
#include "rsa.h"
#include "packet.h"
@@ -24,6 +24,7 @@ RCSID("$Id: auth-rsa.c,v 1.18 2000/02/11 10:59:11 markus Exp $");
#include "ssh.h"
#include "mpaux.h"
#include "uidswap.h"
+#include "match.h"
#include "servconf.h"
#include <ssl/rsa.h>
@@ -60,10 +61,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;
@@ -76,19 +76,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);
@@ -140,7 +132,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);
@@ -202,8 +194,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
@@ -241,7 +234,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",
@@ -251,19 +244,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.");
@@ -466,8 +460,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/crypto/openssh/bufaux.c b/crypto/openssh/bufaux.c
index 5091968c5644..dddc41f9c69d 100644
--- a/crypto/openssh/bufaux.c
+++ b/crypto/openssh/bufaux.c
@@ -15,7 +15,7 @@
*/
#include "includes.h"
-RCSID("$Id: bufaux.c,v 1.7 1999/11/24 19:53:44 markus Exp $");
+RCSID("$Id: bufaux.c,v 1.8 2000/03/16 20:56:14 markus Exp $");
#include "ssh.h"
#include <ssl/bn.h>
@@ -32,7 +32,7 @@ buffer_put_bignum(Buffer *buffer, BIGNUM *value)
{
int bits = BN_num_bits(value);
int bin_size = (bits + 7) / 8;
- char *buf = xmalloc(bin_size);
+ char unsigned *buf = xmalloc(bin_size);
int oi;
char msg[2];
@@ -46,7 +46,7 @@ buffer_put_bignum(Buffer *buffer, BIGNUM *value)
PUT_16BIT(msg, bits);
buffer_append(buffer, msg, 2);
/* Store the binary data. */
- buffer_append(buffer, buf, oi);
+ buffer_append(buffer, (char *)buf, oi);
memset(buf, 0, bin_size);
xfree(buf);
@@ -68,7 +68,7 @@ buffer_get_bignum(Buffer *buffer, BIGNUM *value)
bytes = (bits + 7) / 8;
if (buffer_len(buffer) < bytes)
fatal("buffer_get_bignum: input buffer too small");
- bin = buffer_ptr(buffer);
+ bin = (unsigned char*) buffer_ptr(buffer);
BN_bin2bn(bin, bytes, value);
buffer_consume(buffer, bytes);
diff --git a/crypto/openssh/channels.c b/crypto/openssh/channels.c
index b40e965d8a2c..62b6a2269531 100644
--- a/crypto/openssh/channels.c
+++ b/crypto/openssh/channels.c
@@ -16,7 +16,7 @@
*/
#include "includes.h"
-RCSID("$Id: channels.c,v 1.38 2000/01/24 20:37:29 markus Exp $");
+RCSID("$Id: channels.c,v 1.39 2000/03/16 20:56:14 markus Exp $");
#include "ssh.h"
#include "packet.h"
@@ -1037,7 +1037,7 @@ channel_input_port_open(int payload_len)
int remote_channel, sock = 0, newch, i;
u_short host_port;
char *host, *originator_string;
- int host_len, originator_len;
+ unsigned int host_len, originator_len;
struct addrinfo hints, *ai, *aitop;
char ntop[NI_MAXHOST], strport[NI_MAXSERV];
int gaierr;
@@ -1284,7 +1284,7 @@ x11_input_open(int payload_len)
int remote_channel, display_number, sock = 0, newch;
const char *display;
char buf[1024], *cp, *remote_host;
- int remote_len;
+ unsigned int remote_len;
struct addrinfo hints, *ai, *aitop;
char strport[NI_MAXSERV];
int gaierr;
diff --git a/crypto/openssh/cipher.c b/crypto/openssh/cipher.c
index 552bbe34d803..682a980175c3 100644
--- a/crypto/openssh/cipher.c
+++ b/crypto/openssh/cipher.c
@@ -12,7 +12,7 @@
*/
#include "includes.h"
-RCSID("$Id: cipher.c,v 1.19 2000/02/22 15:19:29 markus Exp $");
+RCSID("$Id: cipher.c,v 1.20 2000/03/22 09:55:10 markus Exp $");
#include "ssh.h"
#include "cipher.h"
@@ -104,18 +104,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.
@@ -298,7 +286,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,
@@ -306,7 +293,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/crypto/openssh/cipher.h b/crypto/openssh/cipher.h
index 2e06c98f90e9..a6f458a54de9 100644
--- a/crypto/openssh/cipher.h
+++ b/crypto/openssh/cipher.h
@@ -11,7 +11,7 @@
*
*/
-/* RCSID("$Id: cipher.h,v 1.10 1999/11/24 19:53:46 markus Exp $"); */
+/* RCSID("$Id: cipher.h,v 1.11 2000/03/22 09:55:10 markus Exp $"); */
#ifndef CIPHER_H
#define CIPHER_H
@@ -88,10 +88,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/crypto/openssh/compress.c b/crypto/openssh/compress.c
index f4a87857348f..03e508173969 100644
--- a/crypto/openssh/compress.c
+++ b/crypto/openssh/compress.c
@@ -14,7 +14,7 @@
*/
#include "includes.h"
-RCSID("$Id: compress.c,v 1.4 1999/11/24 19:53:46 markus Exp $");
+RCSID("$Id: compress.c,v 1.5 2000/03/16 20:56:14 markus Exp $");
#include "ssh.h"
#include "buffer.h"
@@ -75,13 +75,13 @@ buffer_compress(Buffer * input_buffer, Buffer * output_buffer)
return;
/* Input is the contents of the input buffer. */
- outgoing_stream.next_in = buffer_ptr(input_buffer);
+ outgoing_stream.next_in = (unsigned char *) buffer_ptr(input_buffer);
outgoing_stream.avail_in = buffer_len(input_buffer);
/* Loop compressing until deflate() returns with avail_out != 0. */
do {
/* Set up fixed-size output buffer. */
- outgoing_stream.next_out = buf;
+ outgoing_stream.next_out = (unsigned char *)buf;
outgoing_stream.avail_out = sizeof(buf);
/* Compress as much data into the buffer as possible. */
@@ -124,10 +124,10 @@ buffer_uncompress(Buffer * input_buffer, Buffer * output_buffer)
char buf[4096];
int status;
- incoming_stream.next_in = buffer_ptr(input_buffer);
+ incoming_stream.next_in = (unsigned char *) buffer_ptr(input_buffer);
incoming_stream.avail_in = buffer_len(input_buffer);
- incoming_stream.next_out = buf;
+ incoming_stream.next_out = (unsigned char *) buf;
incoming_stream.avail_out = sizeof(buf);
for (;;) {
@@ -136,7 +136,7 @@ buffer_uncompress(Buffer * input_buffer, Buffer * output_buffer)
case Z_OK:
buffer_append(output_buffer, buf,
sizeof(buf) - incoming_stream.avail_out);
- incoming_stream.next_out = buf;
+ incoming_stream.next_out = (unsigned char *) buf;
incoming_stream.avail_out = sizeof(buf);
break;
case Z_STREAM_END:
diff --git a/crypto/openssh/fingerprint.c b/crypto/openssh/fingerprint.c
index 42b8cd7c8f8a..c001ca2b86e2 100644
--- a/crypto/openssh/fingerprint.c
+++ b/crypto/openssh/fingerprint.c
@@ -28,7 +28,7 @@
*/
#include "includes.h"
-RCSID("$Id: fingerprint.c,v 1.4 1999/11/24 16:15:25 markus Exp $");
+RCSID("$Id: fingerprint.c,v 1.5 2000/03/16 20:56:14 markus Exp $");
#include "ssh.h"
#include "xmalloc.h"
@@ -46,7 +46,7 @@ fingerprint(BIGNUM *e, BIGNUM *n)
static char retval[80];
MD5_CTX md;
unsigned char d[16];
- char *buf;
+ unsigned char *buf;
int nlen, elen;
nlen = BN_num_bytes(n);
diff --git a/crypto/openssh/hostfile.c b/crypto/openssh/hostfile.c
index ea92fa048553..eca68da730d4 100644
--- a/crypto/openssh/hostfile.c
+++ b/crypto/openssh/hostfile.c
@@ -14,63 +14,23 @@
*/
#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 $");
#include "packet.h"
+#include "match.h"
#include "ssh.h"
+#include <ssl/rsa.h>
+#include <ssl/dsa.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 +45,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 +58,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 +92,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 +101,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 +144,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 +178,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/crypto/openssh/hostfile.h b/crypto/openssh/hostfile.h
new file mode 100644
index 000000000000..64fe185da9fa
--- /dev/null
+++ b/crypto/openssh/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/crypto/openssh/key.c b/crypto/openssh/key.c
new file mode 100644
index 000000000000..6ad35cbac9d9
--- /dev/null
+++ b/crypto/openssh/key.c
@@ -0,0 +1,290 @@
+/*
+ * 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"
+#include "ssh.h"
+#include <ssl/rsa.h>
+#include <ssl/dsa.h>
+#include <ssl/evp.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/crypto/openssh/key.h b/crypto/openssh/key.h
new file mode 100644
index 000000000000..70f0c518b8ab
--- /dev/null
+++ b/crypto/openssh/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/crypto/openssh/lib/Makefile b/crypto/openssh/lib/Makefile
index 8f7e4f75afa9..4a9ce1cb0aea 100644
--- a/crypto/openssh/lib/Makefile
+++ b/crypto/openssh/lib/Makefile
@@ -4,7 +4,8 @@ LIB= ssh
SRCS= authfd.c authfile.c bufaux.c buffer.c canohost.c channels.c \
cipher.c compat.c compress.c crc32.c deattack.c fingerprint.c \
hostfile.c log.c match.c mpaux.c nchan.c packet.c readpass.c \
- rsa.c tildexpand.c ttymodes.c uidswap.c xmalloc.c atomicio.c
+ rsa.c tildexpand.c ttymodes.c uidswap.c xmalloc.c atomicio.c \
+ key.c
NOPROFILE= yes
NOPIC= yes
@@ -15,7 +16,7 @@ install:
.include <bsd.own.mk>
.if (${KERBEROS} == "yes")
-CFLAGS+= -DKRB4 -I/usr/include/kerberosIV
+CFLAGS+= -DKRB4 -I${DESTDIR}/usr/include/kerberosIV
.if (${AFS} == "yes")
CFLAGS+= -DAFS
SRCS+= radix.c
diff --git a/crypto/openssh/log-client.c b/crypto/openssh/log-client.c
index 62709d96cdc6..9e20a313afc4 100644
--- a/crypto/openssh/log-client.c
+++ b/crypto/openssh/log-client.c
@@ -15,7 +15,7 @@
*/
#include "includes.h"
-RCSID("$Id: log-client.c,v 1.6 1999/11/24 00:26:02 deraadt Exp $");
+RCSID("$Id: log-client.c,v 1.7 2000/02/27 18:50:09 deraadt Exp $");
#include "xmalloc.h"
#include "ssh.h"
@@ -45,12 +45,12 @@ log_init(char *av0, LogLevel level, SyslogFacility ignored1, int ignored2)
}
}
-#define MSGBUFSIZE 1024
+#define MSGBUFSIZ 1024
void
do_log(LogLevel level, const char *fmt, va_list args)
{
- char msgbuf[MSGBUFSIZE];
+ char msgbuf[MSGBUFSIZ];
if (level > log_level)
return;
diff --git a/crypto/openssh/log-server.c b/crypto/openssh/log-server.c
index 52f56a307e8b..124d7fe6b69b 100644
--- a/crypto/openssh/log-server.c
+++ b/crypto/openssh/log-server.c
@@ -15,7 +15,7 @@
*/
#include "includes.h"
-RCSID("$Id: log-server.c,v 1.11 1999/11/24 00:26:02 deraadt Exp $");
+RCSID("$Id: log-server.c,v 1.12 2000/02/27 18:50:09 deraadt Exp $");
#include <syslog.h>
#include "packet.h"
@@ -91,13 +91,13 @@ log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr)
log_on_stderr = on_stderr;
}
-#define MSGBUFSIZE 1024
+#define MSGBUFSIZ 1024
void
do_log(LogLevel level, const char *fmt, va_list args)
{
- char msgbuf[MSGBUFSIZE];
- char fmtbuf[MSGBUFSIZE];
+ char msgbuf[MSGBUFSIZ];
+ char fmtbuf[MSGBUFSIZ];
char *txt = NULL;
int pri = LOG_INFO;
extern char *__progname;
diff --git a/crypto/openssh/match.c b/crypto/openssh/match.c
index 7a63be63fb98..aadcfd6e940b 100644
--- a/crypto/openssh/match.c
+++ b/crypto/openssh/match.c
@@ -14,7 +14,7 @@
*/
#include "includes.h"
-RCSID("$Id: match.c,v 1.4 1999/11/24 19:53:48 markus Exp $");
+RCSID("$Id: match.c,v 1.5 2000/03/23 22:15:33 markus 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/crypto/openssh/match.h b/crypto/openssh/match.h
new file mode 100644
index 000000000000..4625d97691fb
--- /dev/null
+++ b/crypto/openssh/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/crypto/openssh/packet.h b/crypto/openssh/packet.h
index 055f2c8810cf..66a35286d6a5 100644
--- a/crypto/openssh/packet.h
+++ b/crypto/openssh/packet.h
@@ -13,7 +13,7 @@
*
*/
-/* RCSID("$Id: packet.h,v 1.9 2000/01/04 16:54:58 markus Exp $"); */
+/* RCSID("$Id: packet.h,v 1.10 2000/03/16 20:56:14 markus Exp $"); */
#ifndef PACKET_H
#define PACKET_H
@@ -144,7 +144,7 @@ char *packet_get_string(unsigned int *length_ptr);
* The error message should not contain a newline. The total length of the
* message must not exceed 1024 bytes.
*/
-void packet_disconnect(const char *fmt,...) __attribute__((format(printf, 1, 2)));;
+void packet_disconnect(const char *fmt,...) __attribute__((format(printf, 1, 2)));
/*
* Sends a diagnostic message to the other side. This message can be sent at
@@ -156,7 +156,7 @@ void packet_disconnect(const char *fmt,...) __attribute__((format(printf, 1,
* remote side protocol flags do not indicate that it supports SSH_MSG_DEBUG,
* this will do nothing.
*/
-void packet_send_debug(const char *fmt,...) __attribute__((format(printf, 1, 2)));;
+void packet_send_debug(const char *fmt,...) __attribute__((format(printf, 1, 2)));
/* Checks if there is any buffered output, and tries to write some of the output. */
void packet_write_poll(void);
diff --git a/crypto/openssh/radix.c b/crypto/openssh/radix.c
index c87dd2d35b2e..ea7f5ba2bcac 100644
--- a/crypto/openssh/radix.c
+++ b/crypto/openssh/radix.c
@@ -213,7 +213,7 @@ creds_to_radix(CREDENTIALS *creds, unsigned char *buf)
p += creds->ticket_st.length;
len = p - temp;
- return (uuencode(temp, len, buf));
+ return (uuencode((unsigned char *)temp, len, (char *)buf));
}
int
@@ -225,7 +225,7 @@ radix_to_creds(const char *buf, CREDENTIALS *creds)
char version;
char temp[2048];
- if (!(len = uudecode(buf, temp, sizeof(temp))))
+ if (!(len = uudecode(buf, (unsigned char *)temp, sizeof(temp))))
return 0;
p = temp;
diff --git a/crypto/openssh/readconf.c b/crypto/openssh/readconf.c
index 32afcdd54d75..e9c8455bf100 100644
--- a/crypto/openssh/readconf.c
+++ b/crypto/openssh/readconf.c
@@ -14,7 +14,7 @@
*/
#include "includes.h"
-RCSID("$Id: readconf.c,v 1.22 1999/12/01 13:59:15 markus Exp $");
+RCSID("$Id: readconf.c,v 1.23 2000/02/28 19:51:58 markus Exp $");
#include "ssh.h"
#include "cipher.h"
@@ -638,7 +638,7 @@ fill_default_options(Options * options)
if (options->forward_agent == -1)
options->forward_agent = 1;
if (options->forward_x11 == -1)
- options->forward_x11 = 1;
+ options->forward_x11 = 0;
if (options->gateway_ports == -1)
options->gateway_ports = 0;
if (options->use_privileged_port == -1)
diff --git a/crypto/openssh/rsa.c b/crypto/openssh/rsa.c
index 5cab80489121..955a3f5fd650 100644
--- a/crypto/openssh/rsa.c
+++ b/crypto/openssh/rsa.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-RCSID("$Id: rsa.c,v 1.12 2000/02/21 21:47:31 markus Exp $");
+RCSID("$Id: rsa.c,v 1.13 2000/03/16 20:56:14 markus Exp $");
#include "rsa.h"
#include "ssh.h"
@@ -110,7 +110,7 @@ rsa_generate_key(RSA *prv, RSA *pub, unsigned int bits)
void
rsa_public_encrypt(BIGNUM *out, BIGNUM *in, RSA *key)
{
- char *inbuf, *outbuf;
+ unsigned char *inbuf, *outbuf;
int len, ilen, olen;
if (BN_num_bits(key->e) < 2 || !BN_is_odd(key->e))
@@ -138,7 +138,7 @@ rsa_public_encrypt(BIGNUM *out, BIGNUM *in, RSA *key)
void
rsa_private_decrypt(BIGNUM *out, BIGNUM *in, RSA *key)
{
- char *inbuf, *outbuf;
+ unsigned char *inbuf, *outbuf;
int len, ilen, olen;
olen = BN_num_bytes(key->n);
diff --git a/crypto/openssh/scp.1 b/crypto/openssh/scp.1
index d4c374e5f12c..8e93e23d3fd3 100644
--- a/crypto/openssh/scp.1
+++ b/crypto/openssh/scp.1
@@ -9,7 +9,7 @@
.\"
.\" Created: Sun May 7 00:14:37 1995 ylo
.\"
-.\" $Id: scp.1,v 1.5 2000/01/04 16:57:16 markus Exp $
+.\" $Id: scp.1,v 1.6 2000/03/23 21:10:09 aaron 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/crypto/openssh/scp.c b/crypto/openssh/scp.c
index 16ac0ebc4831..915ef97e7f3c 100644
--- a/crypto/openssh/scp.c
+++ b/crypto/openssh/scp.c
@@ -45,7 +45,7 @@
*/
#include "includes.h"
-RCSID("$Id: scp.c,v 1.25 2000/01/24 22:11:20 markus Exp $");
+RCSID("$Id: scp.c,v 1.26 2000/03/16 20:56:14 markus Exp $");
#include "ssh.h"
#include "xmalloc.h"
@@ -1006,7 +1006,7 @@ run_err(const char *fmt,...)
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: scp.c,v 1.25 2000/01/24 22:11:20 markus Exp $
+ * $Id: scp.c,v 1.26 2000/03/16 20:56:14 markus Exp $
*/
char *
@@ -1118,7 +1118,7 @@ alarmtimer(int wait)
}
void
-updateprogressmeter(void)
+updateprogressmeter(int ignore)
{
int save_errno = errno;
@@ -1224,7 +1224,7 @@ progressmeter(int flag)
atomicio(write, fileno(stdout), buf, strlen(buf));
if (flag == -1) {
- signal(SIGALRM, (void *) updateprogressmeter);
+ signal(SIGALRM, updateprogressmeter);
alarmtimer(1);
} else if (flag == 1) {
alarmtimer(0);
diff --git a/crypto/openssh/servconf.c b/crypto/openssh/servconf.c
index eb1b20e72d81..15b326f918d8 100644
--- a/crypto/openssh/servconf.c
+++ b/crypto/openssh/servconf.c
@@ -12,7 +12,7 @@
*/
#include "includes.h"
-RCSID("$Id: servconf.c,v 1.29 2000/01/04 00:07:59 markus Exp $");
+RCSID("$Id: servconf.c,v 1.31 2000/03/07 20:40:41 markus Exp $");
#include "ssh.h"
#include "servconf.h"
@@ -87,7 +87,7 @@ fill_default_server_options(ServerOptions *options)
if (options->permit_root_login == -1)
options->permit_root_login = 1; /* yes */
if (options->ignore_rhosts == -1)
- options->ignore_rhosts = 0;
+ options->ignore_rhosts = 1;
if (options->ignore_user_known_hosts == -1)
options->ignore_user_known_hosts = 0;
if (options->check_mail == -1)
@@ -95,9 +95,9 @@ fill_default_server_options(ServerOptions *options)
if (options->print_motd == -1)
options->print_motd = 1;
if (options->x11_forwarding == -1)
- options->x11_forwarding = 1;
+ options->x11_forwarding = 0;
if (options->x11_display_offset == -1)
- options->x11_display_offset = 1;
+ options->x11_display_offset = 10;
if (options->strict_modes == -1)
options->strict_modes = 1;
if (options->keepalives == -1)
@@ -109,7 +109,7 @@ fill_default_server_options(ServerOptions *options)
if (options->rhosts_authentication == -1)
options->rhosts_authentication = 0;
if (options->rhosts_rsa_authentication == -1)
- options->rhosts_rsa_authentication = 1;
+ options->rhosts_rsa_authentication = 0;
if (options->rsa_authentication == -1)
options->rsa_authentication = 1;
#ifdef KRB4
@@ -133,7 +133,7 @@ fill_default_server_options(ServerOptions *options)
options->skey_authentication = 1;
#endif
if (options->permit_empty_passwd == -1)
- options->permit_empty_passwd = 1;
+ options->permit_empty_passwd = 0;
if (options->use_login == -1)
options->use_login = 0;
}
@@ -402,7 +402,7 @@ parse_flag:
case sIgnoreUserKnownHosts:
intptr = &options->ignore_user_known_hosts;
- goto parse_int;
+ goto parse_flag;
case sRhostsAuthentication:
intptr = &options->rhosts_authentication;
diff --git a/crypto/openssh/ssh-add.1 b/crypto/openssh/ssh-add.1
index 8872e7154327..8d1486b52dbd 100644
--- a/crypto/openssh/ssh-add.1
+++ b/crypto/openssh/ssh-add.1
@@ -9,7 +9,7 @@
.\"
.\" Created: Sat Apr 22 23:55:14 1995 ylo
.\"
-.\" $Id: ssh-add.1,v 1.10 2000/01/22 02:17:50 aaron Exp $
+.\" $Id: ssh-add.1,v 1.11 2000/03/23 21:11:38 aaron 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/crypto/openssh/ssh-agent.1 b/crypto/openssh/ssh-agent.1
index b98775d90bca..7029b60dcc47 100644
--- a/crypto/openssh/ssh-agent.1
+++ b/crypto/openssh/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/crypto/openssh/ssh-agent.c b/crypto/openssh/ssh-agent.c
index 6646956ea7f1..393fdf017456 100644
--- a/crypto/openssh/ssh-agent.c
+++ b/crypto/openssh/ssh-agent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-agent.c,v 1.25 2000/01/02 21:51:03 markus Exp $ */
+/* $OpenBSD: ssh-agent.c,v 1.26 2000/03/16 20:56:14 markus Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -9,7 +9,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-agent.c,v 1.25 2000/01/02 21:51:03 markus Exp $");
+RCSID("$OpenBSD: ssh-agent.c,v 1.26 2000/03/16 20:56:14 markus Exp $");
#include "ssh.h"
#include "rsa.h"
@@ -408,6 +408,7 @@ after_select(fd_set *readset, fd_set *writeset)
{
unsigned int i;
int len, sock;
+ socklen_t slen;
char buf[1024];
struct sockaddr_un sunaddr;
@@ -417,8 +418,8 @@ after_select(fd_set *readset, fd_set *writeset)
break;
case AUTH_SOCKET:
if (FD_ISSET(sockets[i].fd, readset)) {
- len = sizeof(sunaddr);
- sock = accept(sockets[i].fd, (struct sockaddr *) & sunaddr, &len);
+ slen = sizeof(sunaddr);
+ sock = accept(sockets[i].fd, (struct sockaddr *) & sunaddr, &slen);
if (sock < 0) {
perror("accept from AUTH_SOCKET");
break;
diff --git a/crypto/openssh/ssh-keygen.1 b/crypto/openssh/ssh-keygen.1
index e7c837c79fbd..90361643c7b3 100644
--- a/crypto/openssh/ssh-keygen.1
+++ b/crypto/openssh/ssh-keygen.1
@@ -9,7 +9,7 @@
.\"
.\" Created: Sat Apr 22 23:55:14 1995 ylo
.\"
-.\" $Id: ssh-keygen.1,v 1.11 2000/01/22 02:17:50 aaron Exp $
+.\" $Id: ssh-keygen.1,v 1.12 2000/03/23 21:10:10 aaron 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/crypto/openssh/ssh-keygen.c b/crypto/openssh/ssh-keygen.c
index 93ae2da0e42a..29a967dbf485 100644
--- a/crypto/openssh/ssh-keygen.c
+++ b/crypto/openssh/ssh-keygen.c
@@ -7,7 +7,7 @@
*/
#include "includes.h"
-RCSID("$Id: ssh-keygen.c,v 1.16 2000/02/04 14:34:09 markus Exp $");
+RCSID("$Id: ssh-keygen.c,v 1.17 2000/03/16 20:56:14 markus Exp $");
#include "rsa.h"
#include "ssh.h"
@@ -81,6 +81,7 @@ do_fingerprint(struct passwd *pw)
RSA *public_key;
char *comment = NULL, *cp, *ep, line[16*1024];
int i, skip = 0, num = 1, invalid = 1;
+ unsigned int ignore;
struct stat st;
if (!have_identity)
@@ -138,7 +139,7 @@ do_fingerprint(struct passwd *pw)
*cp++ = '\0';
}
ep = cp;
- if (auth_rsa_read_key(&cp, &i, e, n)) {
+ if (auth_rsa_read_key(&cp, &ignore, e, n)) {
invalid = 0;
comment = *cp ? cp : comment;
printf("%d %s %s\n", BN_num_bits(n),
diff --git a/crypto/openssh/ssh.1 b/crypto/openssh/ssh.1
index 9851702e0b9c..b2bd31c0cbde 100644
--- a/crypto/openssh/ssh.1
+++ b/crypto/openssh/ssh.1
@@ -9,7 +9,7 @@
.\"
.\" Created: Sat Apr 22 21:55:14 1995 ylo
.\"
-.\" $Id: ssh.1,v 1.37 2000/02/21 14:19:09 deraadt Exp $
+.\" $Id: ssh.1,v 1.43 2000/03/24 03:04:46 brad Exp $
.\"
.Dd September 25, 1999
.Dt SSH 1
@@ -52,9 +52,11 @@
.Sh DESCRIPTION
.Nm
(Secure Shell) is a program for logging into a remote machine and for
-executing commands on a remote machine. It is intended to replace
+executing commands on a remote machine.
+It is intended to replace
rlogin and rsh, and provide secure encrypted communications between
-two untrusted hosts over an insecure network. X11 connections and
+two untrusted hosts over an insecure network.
+X11 connections and
arbitrary TCP/IP ports can also be forwarded over the secure channel.
.Pp
.Nm
@@ -76,15 +78,16 @@ or
exists in the user's home directory on the
remote machine and contains a line containing the name of the client
machine and the name of the user on that machine, the user is
-permitted to log in. This form of authentication alone is normally not
+permitted to log in.
+This form of authentication alone is normally not
allowed by the server because it is not secure.
.Pp
The second (and primary) authentication method is the
.Pa rhosts
or
.Pa hosts.equiv
-method combined with RSA-based host authentication. It
-means that if the login would be permitted by
+method combined with RSA-based host authentication.
+It means that if the login would be permitted by
.Pa \&.rhosts ,
.Pa \&.shosts ,
.Pa /etc/hosts.equiv ,
@@ -97,10 +100,10 @@ and
.Pa $HOME/.ssh/known_hosts
in the
.Sx FILES
-section), only then login is
-permitted. This authentication method closes security holes due to IP
-spoofing, DNS spoofing and routing spoofing. [Note to the
-administrator:
+section), only then login is permitted.
+This authentication method closes security holes due to IP
+spoofing, DNS spoofing and routing spoofing.
+[Note to the administrator:
.Pa /etc/hosts.equiv ,
.Pa \&.rhosts ,
and the rlogin/rsh protocol in general, are inherently insecure and should be
@@ -112,34 +115,39 @@ supports RSA based authentication.
The scheme is based on public-key cryptography: there are cryptosystems
where encryption and decryption are done using separate keys, and it
is not possible to derive the decryption key from the encryption key.
-RSA is one such system. The idea is that each user creates a public/private
-key pair for authentication purposes. The
-server knows the public key, and only the user knows the private key.
+RSA is one such system.
+The idea is that each user creates a public/private
+key pair for authentication purposes.
+The server knows the public key, and only the user knows the private key.
The file
.Pa $HOME/.ssh/authorized_keys
lists the public keys that are permitted for logging
-in. When the user logs in, the
+in.
+When the user logs in, the
.Nm
program tells the server which key pair it would like to use for
-authentication. The server checks if this key is permitted, and if
+authentication.
+The server checks if this key is permitted, and if
so, sends the user (actually the
.Nm
program running on behalf of the user) a challenge, a random number,
-encrypted by the user's public key. The challenge can only be
-decrypted using the proper private key. The user's client then decrypts the
+encrypted by the user's public key.
+The challenge can only be
+decrypted using the proper private key.
+The user's client then decrypts the
challenge using the private key, proving that he/she knows the private
key but without disclosing it to the server.
.Pp
.Nm
-implements the RSA authentication protocol automatically. The user
-creates his/her RSA key pair by running
+implements the RSA authentication protocol automatically.
+The user creates his/her RSA key pair by running
.Xr ssh-keygen 1 .
This stores the private key in
.Pa \&.ssh/identity
and the public key in
.Pa \&.ssh/identity.pub
-in the user's home directory. The user should then
-copy the
+in the user's home directory.
+The user should then copy the
.Pa identity.pub
to
.Pa \&.ssh/authorized_keys
@@ -148,24 +156,28 @@ in his/her home directory on the remote machine (the
file corresponds to the conventional
.Pa \&.rhosts
file, and has one key
-per line, though the lines can be very long). After this, the user
-can log in without giving the password. RSA authentication is much
+per line, though the lines can be very long).
+After this, the user can log in without giving the password.
+RSA authentication is much
more secure than rhosts authentication.
.Pp
The most convenient way to use RSA authentication may be with an
-authentication agent. See
+authentication agent.
+See
.Xr ssh-agent 1
for more information.
.Pp
If other authentication methods fail,
.Nm
-prompts the user for a password. The password is sent to the remote
+prompts the user for a password.
+The password is sent to the remote
host for checking; however, since all communications are encrypted,
the password cannot be seen by someone listening on the network.
.Pp
When the user's identity has been accepted by the server, the server
either executes the given command, or logs into the machine and gives
-the user a normal shell on the remote machine. All communication with
+the user a normal shell on the remote machine.
+All communication with
the remote command or shell will be automatically encrypted.
.Pp
If a pseudo-terminal has been allocated (normal login session), the
@@ -182,19 +194,22 @@ the session blocks waiting for forwarded X11 or TCP/IP
connections to terminate, it can be backgrounded with
.Ic ~&
(this should not be used while the user shell is active, as it can cause the
-shell to hang). All available escapes can be listed with
+shell to hang).
+All available escapes can be listed with
.Ic ~? .
.Pp
A single tilde character can be sent as
.Ic ~~
(or by following the tilde by a character other than those described above).
The escape character must always follow a newline to be interpreted as
-special. The escape character can be changed in configuration files
-or on the command line.
+special.
+The escape character can be changed in configuration files
+or on the command line.
.Pp
If no pseudo tty has been allocated, the
session is transparent and can be used to reliably transfer binary
-data. On most systems, setting the escape character to
+data.
+On most systems, setting the escape character to
.Dq none
will also make the session transparent even if a tty is used.
.Pp
@@ -210,7 +225,8 @@ environment variable is set), the connection to the X11 display is
automatically forwarded to the remote side in such a way that any X11
programs started from the shell (or command) will go through the
encrypted channel, and the connection to the real X server will be made
-from the local machine. The user should not manually set
+from the local machine.
+The user should not manually set
.Ev DISPLAY .
Forwarding of X11 connections can be
configured on the command line or in configuration files.
@@ -220,7 +236,8 @@ The
value set by
.Nm
will point to the server machine, but with a display number greater
-than zero. This is normal, and happens because
+than zero.
+This is normal, and happens because
.Nm
creates a
.Dq proxy
@@ -232,7 +249,8 @@ will also automatically set up Xauthority data on the server machine.
For this purpose, it will generate a random authorization cookie,
store it in Xauthority on the server, and verify that any forwarded
connections carry this cookie and replace it by the real cookie when
-the connection is opened. The real authentication cookie is never
+the connection is opened.
+The real authentication cookie is never
sent to the server machine (and no cookies are sent in the plain).
.Pp
If the user is using an authentication agent, the connection to the agent
@@ -240,37 +258,42 @@ is automatically forwarded to the remote side unless disabled on
command line or in a configuration file.
.Pp
Forwarding of arbitrary TCP/IP connections over the secure channel can
-be specified either on command line or in a configuration file. One
-possible application of TCP/IP forwarding is a secure connection to an
+be specified either on command line or in a configuration file.
+One possible application of TCP/IP forwarding is a secure connection to an
electronic purse; another is going trough firewalls.
.Pp
.Nm
automatically maintains and checks a database containing RSA-based
-identifications for all hosts it has ever been used with. The
-database is stored in
+identifications for all hosts it has ever been used with.
+The database is stored in
.Pa \&.ssh/known_hosts
-in the user's home directory. Additionally, the file
+in the user's home directory.
+Additionally, the file
.Pa /etc/ssh_known_hosts
-is automatically checked for known hosts. Any new hosts are
-automatically added to the user's file. If a host's identification
+is automatically checked for known hosts.
+Any new hosts are automatically added to the user's file.
+If a host's identification
ever changes,
.Nm
warns about this and disables password authentication to prevent a
-trojan horse from getting the user's password. Another purpose of
+trojan horse from getting the user's password.
+Another purpose of
this mechanism is to prevent man-in-the-middle attacks which could
-otherwise be used to circumvent the encryption. The
+otherwise be used to circumvent the encryption.
+The
.Cm StrictHostKeyChecking
option (see below) can be used to prevent logins to machines whose
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
-is used by default. It is believed to be secure.
+is used by default.
+It is believed to be secure.
.Ar 3des
(triple-des) is an encrypt-decrypt-encrypt triple with three different keys.
It is presumably more secure than the
@@ -278,26 +301,28 @@ It is presumably more secure than the
cipher which is no longer supported in ssh.
.Ar blowfish
is a fast block cipher, it appears very secure and is much faster than
-.Ar 3des .
+.Ar 3des .
.It Fl e Ar ch|^ch|none
Sets the escape character for sessions with a pty (default:
.Ql ~ ) .
-The escape character is only recognized at the beginning of a line. The
-escape character followed by a dot
+The escape character is only recognized at the beginning of a line.
+The escape character followed by a dot
.Pq Ql \&.
closes the connection, followed
by control-Z suspends the connection, and followed by itself sends the
-escape character once. Setting the character to
+escape character once.
+Setting the character to
.Dq none
disables any escapes and makes the session fully transparent.
.It Fl f
Requests
.Nm
-to go to background just before command execution. This is useful
-if
+to go to background just before command execution.
+This is useful if
.Nm
is going to ask for passwords or passphrases, but the user
-wants it in the background. This implies
+wants it in the background.
+This implies
.Fl n .
The recommended way to start X11 programs at a remote site is with
something like
@@ -306,28 +331,31 @@ something like
Allows remote hosts to connect to local forwarded ports.
.It Fl i Ar identity_file
Selects the file from which the identity (private key) for
-RSA authentication is read. Default is
+RSA authentication is read.
+Default is
.Pa \&.ssh/identity
-in the user's home directory. Identity files may also be specified on
-a per-host basis in the configuration file. It is possible to have
-multiple
+in the user's home directory.
+Identity files may also be specified on
+a per-host basis in the configuration file.
+It is possible to have multiple
.Fl i
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 may also
-be specified on a per-host basis in the configuration file.
+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.
.It Fl n
Redirects stdin from
.Pa /dev/null
(actually, prevents reading from stdin).
This must be used when
.Nm
-is run in the background. A common trick is to use this to run X11
-programs in a remote machine. For example,
+is run in the background.
+A common trick is to use this to run X11 programs on a remote machine.
+For example,
.Ic ssh -n shadows.cs.hut.fi emacs &
will start an emacs on shadows.cs.hut.fi, and the X11
connection will be automatically forwarded over an encrypted channel.
@@ -342,10 +370,11 @@ option.)
.It Fl o Ar option
Can be used to give options in the format used in the config file.
This is useful for specifying options for which there is no separate
-command-line flag. The option has the same format as a line in the
-configuration file.
+command-line flag.
+The option has the same format as a line in the configuration file.
.It Fl p Ar port
-Port to connect to on the remote host. This can be specified on a
+Port to connect to on the remote host.
+This can be specified on a
per-host basis in the configuration file.
.It Fl P
Use a non-privileged port for outgoing connections.
@@ -356,35 +385,40 @@ Note that this option turns off
and
.Cm RhostsRSAAuthentication .
.It Fl q
-Quiet mode. Causes all warning and diagnostic messages to be
-suppressed. Only fatal errors are displayed.
+Quiet mode.
+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
-screen-based programs on a remote machine, which can be very useful
-e.g. when implementing menu services.
+Force pseudo-tty allocation.
+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
-Verbose mode. Causes
+Verbose mode.
+Causes
.Nm
-to print debugging messages about its progress. This is helpful in
+to print debugging messages about its progress.
+This is helpful in
debugging connection, authentication, and configuration problems.
The verbose mode is also used to display
.Xr skey 1
challenges, if the user entered "s/key" as password.
.It Fl x
-Disables X11 forwarding. This can also be specified on a per-host
-basis in a configuration file.
+Disables X11 forwarding.
+This can also be specified on a per-host basis in a configuration file.
.It Fl X
Enables X11 forwarding.
.It Fl C
Requests compression of all data (including stdin, stdout, stderr, and
-data for forwarded X11 and TCP/IP connections). The compression
-algorithm is the same used by
+data for forwarded X11 and TCP/IP connections).
+The compression algorithm is the same used by
.Xr gzip 1 ,
and the
.Dq level
can be controlled by the
.Cm CompressionLevel
-option (see below). Compression is desirable on modem lines and other
+option (see below).
+Compression is desirable on modem lines and other
slow connections, but will only slow down things on fast networks.
The default value can be set on a host-by-host basis in the
configuration files; see the
@@ -392,8 +426,8 @@ configuration files; see the
option below.
.It Fl L Ar port:host:hostport
Specifies that the given port on the local (client) host is to be
-forwarded to the given host and port on the remote side. This works
-by allocating a socket to listen to
+forwarded to the given host and port on the remote side.
+This works by allocating a socket to listen to
.Ar port
on the local side, and whenever a connection is made to this port, the
connection is forwarded over the secure channel, and a connection is
@@ -401,14 +435,15 @@ made to
.Ar host
port
.Ar hostport
-from the remote machine. Port forwardings can also be specified in the
-configuration file. Only root can forward privileged ports.
+from the remote machine.
+Port forwardings can also be specified in the configuration file.
+Only root can forward privileged ports.
IPv6 addresses can be specified with an alternative syntax:
.Ar port/host/hostport
.It Fl R Ar port:host:hostport
Specifies that the given port on the remote (server) host is to be
-forwarded to the given host and port on the local side. This works
-by allocating a socket to listen to
+forwarded to the given host and port on the local side.
+This works by allocating a socket to listen to
.Ar port
on the remote side, and whenever a connection is made to this port, the
connection is forwarded over the secure channel, and a connection is
@@ -416,8 +451,9 @@ made to
.Ar host
port
.Ar hostport
-from the local machine. Port forwardings can also be specified in the
-configuration file. Privileged ports can be forwarded only when
+from the local machine.
+Port forwardings can also be specified in the configuration file.
+Privileged ports can be forwarded only when
logging in as root on the remote machine.
.It Fl 4
Forces
@@ -436,10 +472,12 @@ command line options, user's configuration file
and system-wide configuration file
.Pq Pa /etc/ssh_config .
For each parameter, the first obtained value
-will be used. The configuration files contain sections bracketed by
-"Host" specifications, and that section is only applied for hosts that
-match one of the patterns given in the specification. The matched
-host name is the one given on the command line.
+will be used.
+The configuration files contain sections bracketed by
+.Dq Host
+specifications, and that section is only applied for hosts that
+match one of the patterns given in the specification.
+The matched host name is the one given on the command line.
.Pp
Since the first obtained value for each parameter is used, more
host-specific declarations should be given near the beginning of the
@@ -466,25 +504,28 @@ given after the keyword.
and
.Ql ?
can be used as wildcards in the
-patterns. A single
+patterns.
+A single
.Ql \&*
as a pattern can be used to provide global
-defaults for all hosts. The host is the
+defaults for all hosts.
+The host is the
.Ar hostname
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 .
.It Cm BatchMode
If set to
.Dq yes ,
-passphrase/password querying will be disabled. This
-option is useful in scripts and other batch jobs where you have no
-user to supply the password. The argument must be
+passphrase/password querying will be disabled.
+This option is useful in scripts and other batch jobs where you have no
+user to supply the password.
+The argument must be
.Dq yes
or
.Dq no .
@@ -493,38 +534,43 @@ 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.
.It Cm Cipher
-Specifies the cipher to use for encrypting the session. Currently,
+Specifies the cipher to use for encrypting the session.
+Currently,
.Dq blowfish ,
and
.Dq 3des
-are supported. The default is
+are supported.
+The default is
.Dq 3des .
.It Cm Compression
-Specifies whether to use compression. The argument must be
+Specifies whether to use compression.
+The argument must be
.Dq yes
or
.Dq no .
.It Cm CompressionLevel
-Specifies the compression level to use if compression is enable. The
-argument must be an integer from 1 (fast) to 9 (slow, best). The
-default level is 6, which is good for most applications. The meaning
-of the values is the same as in
+Specifies the compression level to use if compression is enable.
+The argument must be an integer from 1 (fast) to 9 (slow, best).
+The default level is 6, which is good for most applications.
+The meaning of the values is the same as in
.Xr gzip 1 .
.It Cm ConnectionAttempts
Specifies the number of tries (one per second) to make before falling
-back to rsh or exiting. The argument must be an integer. This may be
-useful in scripts if the connection sometimes fails.
+back to rsh or exiting.
+The argument must be an integer.
+This may be useful in scripts if the connection sometimes fails.
.It Cm EscapeChar
Sets the escape character (default:
.Ql ~ ) .
The escape character can also
-be set on the command line. The argument should be a single
-character,
+be set on the command line.
+The argument should be a single character,
.Ql ^
followed by a letter, or
.Dq none
@@ -539,13 +585,15 @@ fails due to a connection refused error (there is no
listening on the remote host),
.Xr rsh 1
should automatically be used instead (after a suitable warning about
-the session being unencrypted). The argument must be
+the session being unencrypted).
+The argument must be
.Dq yes
or
.Dq no .
.It Cm ForwardAgent
Specifies whether the connection to the authentication agent (if any)
-will be forwarded to the remote machine. The argument must be
+will be forwarded to the remote machine.
+The argument must be
.Dq yes
or
.Dq no .
@@ -553,10 +601,13 @@ or
Specifies whether X11 connections will be automatically redirected
over the secure channel and
.Ev DISPLAY
-set. The argument must be
+set.
+The argument must be
.Dq yes
or
.Dq no .
+The default is
+.Dq no .
.It Cm GatewayPorts
Specifies whether remote hosts are allowed to connect to local
forwarded ports.
@@ -570,10 +621,10 @@ The default is
Specifies a file to use instead of
.Pa /etc/ssh_known_hosts .
.It Cm HostName
-Specifies the real host name to log into. This can be used to specify
-nicnames or abbreviations for hosts. Default is the name given on the
-command line. Numeric IP addresses are also permitted (both on the
-command line and in
+Specifies the real host name to log into.
+This can be used to specify nicknames or abbreviations for hosts.
+Default is the name given on the command line.
+Numeric IP addresses are also permitted (both on the command line and in
.Cm HostName
specifications).
.It Cm IdentityFile
@@ -582,75 +633,89 @@ is read (default
.Pa .ssh/identity
in the user's home directory).
Additionally, any identities represented by the authentication agent
-will be used for authentication. The file name may use the tilde
-syntax to refer to a user's home directory. It is possible to have
+will be used for authentication.
+The file name may use the tilde
+syntax to refer to a user's home directory.
+It is possible to have
multiple identity files specified in configuration files; all these
identities will be tried in sequence.
.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.
+find it annoying.
.Pp
The default is
.Dq yes
(to send keepalives), and the client will notice
-if the network goes down or the remote host dies. This is important
-in scripts, and many users want it too.
+if the network goes down or the remote host dies.
+This is important in scripts, and many users want it too.
.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 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 .
.It Cm LocalForward
Specifies that a TCP/IP port on the local machine be forwarded over
-the secure channel to given host:port from the remote machine. The
-first argument must be a port number, and the second must be
-host:port. Multiple forwardings may be specified, and additional
-forwardings can be given on the command line. Only the root can
-forward privileged ports.
+the secure channel to given host:port from the remote machine.
+The first argument must be a port number, and the second must be
+host:port.
+Multiple forwardings may be specified, and additional
+forwardings can be given on the command line.
+Only the superuser can forward privileged ports.
.It Cm LogLevel
Gives the verbosity level that is used when logging messages from
.Nm ssh .
The possible values are:
-QUIET, FATAL, ERROR, INFO, CHAT and DEBUG.
+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
+Specifies whether to use password authentication.
+The argument to this keyword must be
.Dq yes
or
.Dq no .
.It Cm Port
-Specifies the port number to connect on the remote host. Default is
-22.
+Specifies the port number to connect on the remote host.
+Default is 22.
.It Cm ProxyCommand
-Specifies the command to use to connect to the server. The command
-string extends to the end of the line, and is executed with /bin/sh.
-In the command string, %h will be substituted by the host name to
-connect and %p by the port. The command can be basically anything,
-and should read from its stdin and write to its stdout. It should
-eventually connect an
+Specifies the command to use to connect to the server.
+The command
+string extends to the end of the line, and is executed with
+.Pa /bin/sh .
+In the command string,
+.Ql %h
+will be substituted by the host name to
+connect and
+.Ql %p
+by the port.
+The command can be basically anything,
+and should read from its standard input and write to its standard output.
+It should eventually connect an
.Xr sshd 8
server running on some machine, or execute
.Ic sshd -i
-somewhere. Host key management will be done using the
+somewhere.
+Host key management will be done using the
HostName of the host being connected (defaulting to the name typed by
the user).
Note that
@@ -659,32 +724,37 @@ is not available for connects with a proxy command.
.Pp
.It Cm RemoteForward
Specifies that a TCP/IP port on the remote machine be forwarded over
-the secure channel to given host:port from the local machine. The
-first argument must be a port number, and the second must be
-host:port. Multiple forwardings may be specified, and additional
-forwardings can be given on the command line. Only the root can
-forward privileged ports.
+the secure channel to given host:port from the local machine.
+The first argument must be a port number, and the second must be
+host:port.
+Multiple forwardings may be specified, and additional
+forwardings can be given on the command line.
+Only the superuser can forward privileged ports.
.It Cm RhostsAuthentication
-Specifies whether to try rhosts based authentication. Note that this
+Specifies whether to try rhosts based authentication.
+Note that this
declaration only affects the client side and has no effect whatsoever
-on security. Disabling rhosts authentication may reduce
+on security.
+Disabling rhosts authentication may reduce
authentication time on slow connections when rhosts authentication is
-not used. Most servers do not permit RhostsAuthentication because it
-is not secure (see RhostsRSAAuthentication). The argument to this
-keyword must be
+not used.
+Most servers do not permit RhostsAuthentication because it
+is not secure (see RhostsRSAAuthentication).
+The argument to this keyword must be
.Dq yes
or
.Dq no .
.It Cm RhostsRSAAuthentication
Specifies whether to try rhosts based authentication with RSA host
-authentication. This is the primary authentication method for most
-sites. The argument must be
+authentication.
+This is the primary authentication method for most sites.
+The argument must be
.Dq yes
or
.Dq no .
.It Cm RSAAuthentication
-Specifies whether to try RSA authentication. The argument to this
-keyword must be
+Specifies whether to try RSA authentication.
+The argument to this keyword must be
.Dq yes
or
.Dq no .
@@ -694,8 +764,8 @@ running.
.It Cm SkeyAuthentication
Specifies whether to use
.Xr skey 1
-authentication. The argument to
-this keyword must be
+authentication.
+The argument to this keyword must be
.Dq yes
or
.Dq no .
@@ -707,16 +777,19 @@ If this flag is set to
.Nm
ssh will never automatically add host keys to the
.Pa $HOME/.ssh/known_hosts
-file, and refuses to connect hosts whose host key has changed. This
-provides maximum protection against trojan horse attacks. However, it
-can be somewhat annoying if you don't have good
+file, and refuses to connect hosts whose host key has changed.
+This provides maximum protection against trojan horse attacks.
+However, it can be somewhat annoying if you don't have good
.Pa /etc/ssh_known_hosts
files installed and frequently
-connect new hosts. Basically this option forces the user to manually
-add any new hosts. Normally this option is disabled, and new hosts
-will automatically be added to the known host files. The host keys of
-known hosts will be verified automatically in either case. The
-argument must be
+connect new hosts.
+Basically this option forces the user to manually
+add any new hosts.
+Normally this option is disabled, and new hosts
+will automatically be added to the known host files.
+The host keys of
+known hosts will be verified automatically in either case.
+The argument must be
.Dq yes
or
.Dq no .
@@ -735,23 +808,26 @@ turns off
and
.Cm RhostsRSAAuthentication .
.It Cm User
-Specifies the user to log in as. This can be useful if you have a
-different user name in different machines. This saves the trouble of
+Specifies the user to log in as.
+This can be useful if you have a different user name on different machines.
+This saves the trouble of
having to remember to give the user name on the command line.
.It Cm UserKnownHostsFile
Specifies a file to use instead of
.Pa $HOME/.ssh/known_hosts .
.It Cm UseRsh
-Specifies that rlogin/rsh should be used for this host. It is
-possible that the host does not at all support the
+Specifies that rlogin/rsh should be used for this host.
+It is possible that the host does not at all support the
.Nm
-protocol. This causes
+protocol.
+This causes
.Nm
-to immediately exec
+to immediately execute
.Xr rsh 1 .
All other options (except
.Cm HostName )
-are ignored if this has been specified. The argument must be
+are ignored if this has been specified.
+The argument must be
.Dq yes
or
.Dq no .
@@ -762,15 +838,17 @@ will normally set the following environment variables:
.It Ev DISPLAY
The
.Ev DISPLAY
-variable indicates the location of the X11 server. It is
-automatically set by
+variable indicates the location of the X11 server.
+It is automatically set by
.Nm
to point to a value of the form
.Dq hostname:n
where hostname indicates
-the host where the shell runs, and n is an integer >= 1. Ssh uses
-this special value to forward X11 connections over the secure
-channel. The user should normally not set DISPLAY explicitly, as that
+the host where the shell runs, and n is an integer >= 1.
+.Nm
+uses this special value to forward X11 connections over the secure
+channel.
+The user should normally not set DISPLAY explicitly, as that
will render the X11 connection insecure (and will require the user to
manually copy any required authorization cookies).
.It Ev HOME
@@ -781,7 +859,7 @@ Synonym for
set for compatibility with systems that use this variable.
.It Ev MAIL
Set to point the user's mailbox.
-.It Ev PATH
+.It Ev PATH
Set to the default
.Ev PATH ,
as specified when compiling
@@ -790,12 +868,14 @@ as specified when compiling
indicates the path of a unix-domain socket used to communicate with the
agent.
.It Ev SSH_CLIENT
-Identifies the client end of the connection. The variable contains
+Identifies the client end of the connection.
+The variable contains
three space-separated values: client ip-address, client port number,
and server port number.
.It Ev SSH_TTY
This is set to the name of the tty (path to the device) associated
-with the current shell or command. If the current session has no tty,
+with the current shell or command.
+If the current session has no tty,
this variable is not set.
.It Ev TZ
The timezone variable is set to indicate the present timezone if it
@@ -821,7 +901,8 @@ in
See
.Xr sshd 8 .
.It Pa $HOME/.ssh/identity
-Contains the RSA authentication identity of the user. This file
+Contains the RSA authentication identity of the user.
+This file
contains sensitive data and should be readable by the user but not
accessible by others (read/write/execute).
Note that
@@ -832,39 +913,50 @@ generating the key; the passphrase will be used to encrypt the
sensitive part of this file using 3DES.
.It Pa $HOME/.ssh/identity.pub
Contains the public key for authentication (public part of the
-identity file in human-readable form). The contents of this file
-should be added to
+identity file in human-readable form).
+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. This file is not
-sensitive and can (but need not) be readable by anyone. This file is
+where you wish to log in using RSA authentication.
+This file is not
+sensitive and can (but need not) be readable by anyone.
+This file is
never used automatically and is not necessary; it is only provided for
the convenience of the user.
.It Pa $HOME/.ssh/config
-This is the per-user configuration file. The format of this file is
-described above. This file is used by the
+This is the per-user configuration file.
+The format of this file is described above.
+This file is used by the
.Nm
-client. This file does not usually contain any sensitive information,
+client.
+This file does not usually contain any sensitive information,
but the recommended permissions are read/write for the user, and not
accessible by others.
.It Pa $HOME/.ssh/authorized_keys
-Lists the RSA keys that can be used for logging in as this user. The
-format of this file is described in the
+Lists the RSA keys that can be used for logging in as this user.
+The format of this file is described in the
.Xr sshd 8
-manual page. In the simplest form the format is the same as the .pub
+manual page.
+In the simplest form the format is the same as the .pub
identity files (that is, each line contains the number of bits in
modulus, public exponent, modulus, and comment fields, separated by
-spaces). This file is not highly sensitive, but the recommended
+spaces).
+This file is not highly sensitive, but the recommended
permissions are read/write for the user, and not accessible by others.
.It Pa /etc/ssh_known_hosts
-Systemwide list of known host keys. This file should be prepared by the
+Systemwide list of known host keys.
+This file should be prepared by the
system administrator to contain the public host keys of all machines in the
-organization. This file should be world-readable. This file contains
+organization.
+This file should be world-readable.
+This file contains
public keys, one per line, in the following format (fields separated
by spaces): system name, number of bits in modulus, public exponent,
-modulus, and optional comment field. When different names are used
+modulus, and optional comment field.
+When different names are used
for the same machine, all such names should be listed, separated by
-commas. The format is described on the
+commas.
+The format is described on the
.Xr sshd 8
manual page.
.Pp
@@ -876,32 +968,37 @@ does not convert the user-supplied name to a canonical name before
checking the key, because someone with access to the name servers
would then be able to fool host authentication.
.It Pa /etc/ssh_config
-Systemwide configuration file. This file provides defaults for those
+Systemwide configuration file.
+This file provides defaults for those
values that are not specified in the user's configuration file, and
-for those users who do not have a configuration file. This file must
-be world-readable.
+for those users who do not have a configuration file.
+This file must be world-readable.
.It Pa $HOME/.rhosts
This file is used in
.Pa \&.rhosts
authentication to list the
-host/user pairs that are permitted to log in. (Note that this file is
+host/user pairs that are permitted to log in.
+(Note that this file is
also used by rlogin and rsh, which makes using this file insecure.)
Each line of the file contains a host name (in the canonical form
returned by name servers), and then a user name on that host,
-separated by a space. One some machines this file may need to be
+separated by a space.
+One some machines this file may need to be
world-readable if the user's home directory is on a NFS partition,
because
.Xr sshd 8
-reads it as root. Additionally, this file must be owned by the user,
-and must not have write permissions for anyone else. The recommended
+reads it as root.
+Additionally, this file must be owned by the user,
+and must not have write permissions for anyone else.
+The recommended
permission for most machines is read/write for the user, and not
accessible by others.
.Pp
Note that by default
.Xr sshd 8
will be installed so that it requires successful RSA host
-authentication before permitting \s+2.\s0rhosts authentication. If your
-server machine does not have the client's host key in
+authentication before permitting \s+2.\s0rhosts authentication.
+If your server machine does not have the client's host key in
.Pa /etc/ssh_known_hosts ,
you can store it in
.Pa $HOME/.ssh/known_hosts .
@@ -921,14 +1018,18 @@ or
.Xr rsh 1 .
.It Pa /etc/hosts.equiv
This file is used during
-.Pa \&.rhosts authentication. It contains
+.Pa \&.rhosts authentication.
+It contains
canonical hosts names, one per line (the full format is described on
the
.Xr sshd 8
-manual page). If the client host is found in this file, login is
+manual page).
+If the client host is found in this file, login is
automatically permitted provided client and server user names are the
-same. Additionally, successful RSA host authentication is normally
-required. This file should only be writable by root.
+same.
+Additionally, successful RSA host authentication is normally
+required.
+This file should only be writable by root.
.It Pa /etc/shosts.equiv
This file is processed exactly as
.Pa /etc/hosts.equiv .
@@ -960,7 +1061,8 @@ is required for proper operation.
.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/crypto/openssh/ssh.c b/crypto/openssh/ssh.c
index f42fcb6a384a..c5652eaa67e7 100644
--- a/crypto/openssh/ssh.c
+++ b/crypto/openssh/ssh.c
@@ -11,7 +11,7 @@
*/
#include "includes.h"
-RCSID("$Id: ssh.c,v 1.40 2000/02/20 20:05:19 markus Exp $");
+RCSID("$Id: ssh.c,v 1.43 2000/03/23 21:52:02 markus Exp $");
#include "xmalloc.h"
#include "ssh.h"
@@ -93,6 +93,7 @@ usage()
fprintf(stderr, " -k Disable Kerberos ticket and AFS token forwarding.\n");
#endif /* AFS */
fprintf(stderr, " -x Disable X11 connection forwarding.\n");
+ fprintf(stderr, " -X Enable X11 connection forwarding.\n");
fprintf(stderr, " -i file Identity for RSA authentication (default: ~/.ssh/identity).\n");
fprintf(stderr, " -t Tty; allocate a tty even if command is given.\n");
fprintf(stderr, " -v Verbose; display verbose debugging messages.\n");
@@ -170,6 +171,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;
@@ -609,9 +611,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);
@@ -663,9 +662,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.");
@@ -793,7 +793,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/crypto/openssh/ssh.h b/crypto/openssh/ssh.h
index 47872ce8986d..78f95f89d859 100644
--- a/crypto/openssh/ssh.h
+++ b/crypto/openssh/ssh.h
@@ -13,7 +13,7 @@
*
*/
-/* RCSID("$Id: ssh.h,v 1.33 2000/02/01 22:32:53 d Exp $"); */
+/* RCSID("$Id: ssh.h,v 1.34 2000/03/23 22:15:33 markus Exp $"); */
#ifndef SSH_H
#define SSH_H
@@ -313,8 +313,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
@@ -363,40 +362,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/crypto/openssh/ssh/Makefile b/crypto/openssh/ssh/Makefile
index 61a38add711f..b21445506f1b 100644
--- a/crypto/openssh/ssh/Makefile
+++ b/crypto/openssh/ssh/Makefile
@@ -20,7 +20,7 @@ SRCS= ssh.c sshconnect.c log-client.c readconf.c clientloop.c
.include <bsd.own.mk> # for AFS
.if (${KERBEROS} == "yes")
-CFLAGS+= -DKRB4 -I/usr/include/kerberosIV
+CFLAGS+= -DKRB4 -I${DESTDIR}/usr/include/kerberosIV
LDADD+= -lkrb
DPADD+= ${LIBKRB}
.if (${AFS} == "yes")
diff --git a/crypto/openssh/sshconnect.c b/crypto/openssh/sshconnect.c
index 62a842fc1401..07277986949e 100644
--- a/crypto/openssh/sshconnect.c
+++ b/crypto/openssh/sshconnect.c
@@ -8,7 +8,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshconnect.c,v 1.56 2000/02/18 08:50:33 markus Exp $");
+RCSID("$OpenBSD: sshconnect.c,v 1.58 2000/03/23 22:15:33 markus Exp $");
#include <ssl/bn.h>
#include "xmalloc.h"
@@ -21,9 +21,12 @@ RCSID("$OpenBSD: sshconnect.c,v 1.56 2000/02/18 08:50:33 markus Exp $");
#include "uidswap.h"
#include "compat.h"
#include "readconf.h"
-#include "fingerprint.h"
+#include <ssl/rsa.h>
+#include <ssl/dsa.h>
#include <ssl/md5.h>
+#include "key.h"
+#include "hostfile.h"
/* Session id for the current session. */
unsigned char session_id[16];
@@ -632,6 +635,7 @@ try_kerberos_authentication()
char *realm;
CREDENTIALS cred;
int r, type, plen;
+ socklen_t slen;
Key_schedule schedule;
u_long checksum, cksum;
MSG_DAT msg_data;
@@ -674,16 +678,16 @@ try_kerberos_authentication()
/* Zero the buffer. */
(void) memset(auth.dat, 0, MAX_KTXT_LEN);
- r = sizeof(local);
+ slen = sizeof(local);
memset(&local, 0, sizeof(local));
if (getsockname(packet_get_connection_in(),
- (struct sockaddr *) & local, &r) < 0)
+ (struct sockaddr *) & local, &slen) < 0)
debug("getsockname failed: %s", strerror(errno));
- r = sizeof(foreign);
+ slen = sizeof(foreign);
memset(&foreign, 0, sizeof(foreign));
if (getpeername(packet_get_connection_in(),
- (struct sockaddr *) & foreign, &r) < 0) {
+ (struct sockaddr *) & foreign, &slen) < 0) {
debug("getpeername failed: %s", strerror(errno));
fatal_cleanup();
}
@@ -745,7 +749,7 @@ send_kerberos_tgt()
CREDENTIALS *creds;
char pname[ANAME_SZ], pinst[INST_SZ], prealm[REALM_SZ];
int r, type, plen;
- unsigned char buffer[8192];
+ char buffer[8192];
struct stat st;
/* Don't do anything if we don't have any tickets. */
@@ -766,11 +770,11 @@ send_kerberos_tgt()
debug("Kerberos V4 ticket expired: %s", TKT_FILE);
return 0;
}
- creds_to_radix(creds, buffer);
+ creds_to_radix(creds, (unsigned char *)buffer);
xfree(creds);
packet_start(SSH_CMSG_HAVE_KERBEROS_TGT);
- packet_put_string((char *) buffer, strlen(buffer));
+ packet_put_string(buffer, strlen(buffer));
packet_send();
packet_write_wait();
@@ -792,7 +796,7 @@ send_afs_tokens(void)
struct ClearToken ct;
int i, type, len, plen;
char buf[2048], *p, *server_cell;
- unsigned char buffer[8192];
+ char buffer[8192];
/* Move over ktc_GetToken, here's something leaner. */
for (i = 0; i < 100; i++) { /* just in case */
@@ -834,10 +838,10 @@ send_afs_tokens(void)
creds.pinst[0] = '\0';
/* Encode token, ship it off. */
- if (!creds_to_radix(&creds, buffer))
+ if (!creds_to_radix(&creds, (unsigned char*) buffer))
break;
packet_start(SSH_CMSG_HAVE_AFS_TOKEN);
- packet_put_string((char *) buffer, strlen(buffer));
+ packet_put_string(buffer, strlen(buffer));
packet_send();
packet_write_wait();
@@ -861,7 +865,9 @@ send_afs_tokens(void)
int
try_skey_authentication()
{
- int type, i, payload_len;
+ int type, i;
+ int payload_len;
+ unsigned int clen;
char *challenge, *response;
debug("Doing skey authentication.");
@@ -881,7 +887,8 @@ try_skey_authentication()
debug("No challenge for skey authentication.");
return 0;
}
- challenge = packet_get_string(&payload_len);
+ challenge = packet_get_string(&clen);
+ packet_integrity_check(payload_len, (4 + clen), type);
if (options.cipher == SSH_CIPHER_NONE)
log("WARNING: Encryption is disabled! "
"Reponse will be transmitted in clear text.");
@@ -1063,9 +1070,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;
@@ -1115,47 +1122,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:
@@ -1163,8 +1157,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
@@ -1184,12 +1177,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");
}
@@ -1200,8 +1193,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
@@ -1269,6 +1261,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
@@ -1344,7 +1344,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;
@@ -1603,7 +1603,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
@@ -1634,6 +1633,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/crypto/openssh/sshd.8 b/crypto/openssh/sshd.8
index 7aa9cf4b0cee..24b1a352bfe6 100644
--- a/crypto/openssh/sshd.8
+++ b/crypto/openssh/sshd.8
@@ -9,7 +9,7 @@
.\"
.\" Created: Sat Apr 22 21:55:14 1995 ylo
.\"
-.\" $Id: sshd.8,v 1.33 2000/02/21 14:19:09 deraadt Exp $
+.\" $Id: sshd.8,v 1.37 2000/03/24 03:04:46 brad 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.
-However, with small key sizes (e.g. 512) using
+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 ) .
@@ -258,13 +282,17 @@ Note that
.Nm
does not start if this file is group/world-accessible.
.It Cm IgnoreRhosts
-Specifies that rhosts and shosts files will not be used in
-authentication.
+Specifies that
+.Pa .rhosts
+and
+.Pa .shosts
+files will not be used in authentication.
.Pa /etc/hosts.equiv
and
.Pa /etc/shosts.equiv
-are still used. The default is
-.Dq no .
+are still used.
+The default is
+.Dq yes .
.It Cm IgnoreUserKnownHosts
Specifies whether
.Nm
@@ -276,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.
@@ -287,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.
@@ -314,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
@@ -334,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
@@ -350,9 +387,9 @@ 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
-.Dq yes .
+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
.Xr ssh 1 .
@@ -376,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
@@ -402,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
-.Dq yes .
+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
@@ -422,29 +465,35 @@ 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
-.Dq yes .
+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.
.El
@@ -485,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.
@@ -496,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
@@ -509,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
@@ -572,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
@@ -600,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
@@ -632,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
@@ -642,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
@@ -664,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
@@ -674,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
@@ -692,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"
@@ -714,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.
@@ -725,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
@@ -759,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/crypto/openssh/sshd.c b/crypto/openssh/sshd.c
index 6cea307ebbd3..6a5625394ffa 100644
--- a/crypto/openssh/sshd.c
+++ b/crypto/openssh/sshd.c
@@ -11,7 +11,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshd.c,v 1.88 2000/02/15 16:52:57 markus Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.94 2000/03/23 22:15:34 markus Exp $");
#include "xmalloc.h"
#include "rsa.h"
@@ -512,9 +512,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;
@@ -1183,7 +1180,8 @@ void
do_authentication()
{
struct passwd *pw, pwcopy;
- int plen, ulen;
+ int plen;
+ unsigned int ulen;
char *user;
/* Get the name of the user that we wish to log in as. */
@@ -1244,14 +1242,6 @@ do_authentication()
do_authloop(pw);
}
- /* Check if the user is logging in as root and root logins are disallowed. */
- if (pw->pw_uid == 0 && !options.permit_root_login) {
- if (forced_command)
- log("Root login accepted for forced command.");
- else
- packet_disconnect("ROOT LOGIN REFUSED FROM %.200s",
- get_canonical_hostname());
- }
/* The user has been authenticated and accepted. */
packet_start(SSH_SMSG_SUCCESS);
packet_send();
@@ -1274,11 +1264,13 @@ 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, *password;
char user[1024];
- int plen, dlen, nlen, ulen, elen;
+ unsigned int dlen;
+ int plen, nlen, elen;
+ unsigned int ulen;
int type = 0;
void (*authlog) (const char *fmt,...) = verbose;
@@ -1389,21 +1381,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);
xfree(client_user);
@@ -1489,6 +1484,21 @@ do_authloop(struct passwd * pw)
break;
}
+ /*
+ * Check if the user is logging in as root and root logins
+ * are disallowed.
+ * Note that root login is allowed for forced commands.
+ */
+ if (authenticated && pw->pw_uid == 0 && !options.permit_root_login) {
+ if (forced_command) {
+ log("Root login accepted for forced command.");
+ } else {
+ authenticated = 0;
+ log("ROOT LOGIN REFUSED FROM %.200s",
+ get_canonical_hostname());
+ }
+ }
+
/* Raise logging level */
if (authenticated ||
attempt == AUTH_FAIL_LOG ||
@@ -1544,7 +1554,7 @@ do_fake_authloop(char *user)
int plen;
int type = packet_read(&plen);
#ifdef SKEY
- int dlen;
+ unsigned int dlen;
char *password, *skeyinfo;
/* Try to send a fake s/key challenge. */
if (options.skey_authentication == 1 &&
@@ -1628,6 +1638,8 @@ do_authenticated(struct passwd * pw)
int row, col, xpixel, ypixel, screen;
char ttyname[64];
char *command, *term = NULL, *display = NULL, *proto = NULL, *data = NULL;
+ int plen;
+ unsigned int dlen;
int n_bytes;
/*
@@ -1651,7 +1663,6 @@ do_authenticated(struct passwd * pw)
* or a command.
*/
while (1) {
- int plen, dlen;
/* Get a packet from the client. */
type = packet_read(&plen);
@@ -1730,7 +1741,7 @@ do_authenticated(struct passwd * pw)
if (display)
packet_disconnect("Protocol error: X11 display already set.");
{
- int proto_len, data_len;
+ unsigned int proto_len, data_len;
proto = packet_get_string(&proto_len);
data = packet_get_string(&data_len);
packet_integrity_check(plen, 4 + proto_len + 4 + data_len + 4, type);
@@ -1755,8 +1766,9 @@ do_authenticated(struct passwd * pw)
xauthfile = NULL;
goto fail;
}
- restore_uid();
strlcat(xauthfile, "/cookies", MAXPATHLEN);
+ open(xauthfile, O_RDWR|O_CREAT|O_EXCL, 0600);
+ restore_uid();
fatal_add_cleanup(xauthfile_cleanup_proc, NULL);
break;
#else /* XAUTH_PATH */
@@ -1811,7 +1823,7 @@ do_authenticated(struct passwd * pw)
goto do_forced_command;
/* Get command from the packet. */
{
- int dlen;
+ unsigned int dlen;
command = packet_get_string(&dlen);
debug("Executing command '%.500s'", command);
packet_integrity_check(plen, 4 + dlen, type);
@@ -2461,7 +2473,7 @@ do_child(const char *command, struct passwd * pw, const char *term,
f = popen(XAUTH_PATH " -q -", "w");
if (f) {
fprintf(f, "add %s %s %s\n", display, auth_proto, auth_data);
- fclose(f);
+ pclose(f);
} else
fprintf(stderr, "Could not run %s -q -\n", XAUTH_PATH);
}
diff --git a/crypto/openssh/sshd/Makefile b/crypto/openssh/sshd/Makefile
index 15d6eec25546..3815b5a302b9 100644
--- a/crypto/openssh/sshd/Makefile
+++ b/crypto/openssh/sshd/Makefile
@@ -12,15 +12,15 @@ SRCS= sshd.c auth-rhosts.c auth-passwd.c auth-rsa.c auth-rh-rsa.c \
.include <bsd.own.mk> # for KERBEROS and AFS
.if (${KERBEROS} == "yes")
-CFLAGS+= -DKRB4 -I/usr/include/kerberosIV
-SRCS+= auth-krb4.c
-LDADD+= -lkrb
-DPADD+= ${LIBKRB}
.if (${AFS} == "yes")
CFLAGS+= -DAFS
LDADD+= -lkafs
DPADD+= ${LIBKRBAFS}
.endif # AFS
+CFLAGS+= -DKRB4 -I${DESTDIR}/usr/include/kerberosIV
+SRCS+= auth-krb4.c
+LDADD+= -lkrb
+DPADD+= ${LIBKRB}
.endif # KERBEROS
.if (${SKEY} == "yes")
diff --git a/crypto/openssh/version.h b/crypto/openssh/version.h
index c2ef9ff4f202..fe2e876ea87c 100644
--- a/crypto/openssh/version.h
+++ b/crypto/openssh/version.h
@@ -1 +1 @@
-#define SSH_VERSION "OpenSSH-1.2.2"
+#define SSH_VERSION "OpenSSH-1.2.3"