Virgin import of OpenSSH sources dated 2000/03/25
This commit is contained in:
parent
fc557ff7d9
commit
b201b15ee1
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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.");
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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 */
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
auth_rsa_read_key(char **cpp, unsigned int *bitsp, BIGNUM * e, BIGNUM * n)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
int
|
||||
match_hostname(const char *host, const char *pattern, unsigned int len)
|
||||
hostfile_check_key(int bits, Key *key, const char *host, const char *filename, int linenum)
|
||||
{
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
22
crypto/openssh/hostfile.h
Normal file
22
crypto/openssh/hostfile.h
Normal file
@ -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
|
290
crypto/openssh/key.c
Normal file
290
crypto/openssh/key.c
Normal file
@ -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;
|
||||
}
|
23
crypto/openssh/key.h
Normal file
23
crypto/openssh/key.h
Normal file
@ -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
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
18
crypto/openssh/match.h
Normal file
18
crypto/openssh/match.h
Normal file
@ -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
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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();
|
||||
|
@ -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
|
||||
@ -362,41 +361,12 @@ int get_remote_port(void);
|
||||
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
|
||||
|
@ -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")
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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")
|
||||
|
@ -1 +1 @@
|
||||
#define SSH_VERSION "OpenSSH-1.2.2"
|
||||
#define SSH_VERSION "OpenSSH-1.2.3"
|
||||
|
Loading…
x
Reference in New Issue
Block a user