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
|
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
|
network, to execute commands in a remote machine, and to move files
|
||||||
from one machine to another. It provides strong authentication and
|
from one machine to another. It provides strong authentication and
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "xmalloc.h"
|
||||||
#include "ssh.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
|
* ensure all of data on socket comes through. f==read || f==write
|
||||||
*/
|
*/
|
||||||
ssize_t
|
ssize_t
|
||||||
atomicio(f, fd, s, n)
|
atomicio(f, fd, _s, n)
|
||||||
ssize_t (*f) ();
|
ssize_t (*f) ();
|
||||||
int fd;
|
int fd;
|
||||||
void *s;
|
void *_s;
|
||||||
size_t n;
|
size_t n;
|
||||||
{
|
{
|
||||||
|
char *s = _s;
|
||||||
ssize_t res, pos = 0;
|
ssize_t res, pos = 0;
|
||||||
|
|
||||||
while (n > pos) {
|
while (n > pos) {
|
||||||
|
@ -139,7 +139,7 @@ int
|
|||||||
krb4_init(uid_t uid)
|
krb4_init(uid_t uid)
|
||||||
{
|
{
|
||||||
static int cleanup_registered = 0;
|
static int cleanup_registered = 0;
|
||||||
char *tkt_root = TKT_ROOT;
|
const char *tkt_root = TKT_ROOT;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
@ -186,19 +186,20 @@ auth_krb4(const char *server_user, KTEXT auth, char **client)
|
|||||||
KTEXT_ST reply;
|
KTEXT_ST reply;
|
||||||
char instance[INST_SZ];
|
char instance[INST_SZ];
|
||||||
int r, s;
|
int r, s;
|
||||||
|
socklen_t slen;
|
||||||
u_int cksum;
|
u_int cksum;
|
||||||
Key_schedule schedule;
|
Key_schedule schedule;
|
||||||
struct sockaddr_in local, foreign;
|
struct sockaddr_in local, foreign;
|
||||||
|
|
||||||
s = packet_get_connection_in();
|
s = packet_get_connection_in();
|
||||||
|
|
||||||
r = sizeof(local);
|
slen = sizeof(local);
|
||||||
memset(&local, 0, 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));
|
debug("getsockname failed: %.100s", strerror(errno));
|
||||||
r = sizeof(foreign);
|
slen = sizeof(foreign);
|
||||||
memset(&foreign, 0, 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));
|
debug("getpeername failed: %.100s", strerror(errno));
|
||||||
fatal_cleanup();
|
fatal_cleanup();
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "packet.h"
|
||||||
#include "ssh.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 "uidswap.h"
|
||||||
#include "servconf.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
|
* Tries to authenticate the user using the .rhosts file and the host using
|
||||||
* its host key. Returns true if authentication succeeds.
|
* its host key. Returns true if authentication succeeds.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
auth_rhosts_rsa(struct passwd *pw, const char *client_user,
|
auth_rhosts_rsa(struct passwd *pw, const char *client_user, RSA *client_host_key)
|
||||||
BIGNUM *client_host_key_e, BIGNUM *client_host_key_n)
|
|
||||||
{
|
{
|
||||||
extern ServerOptions options;
|
extern ServerOptions options;
|
||||||
const char *canonical_hostname;
|
const char *canonical_hostname;
|
||||||
HostStatus host_status;
|
HostStatus host_status;
|
||||||
BIGNUM *ke, *kn;
|
Key *client_key, *found;
|
||||||
|
|
||||||
debug("Trying rhosts with RSA host authentication for %.100s", client_user);
|
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. */
|
/* Check if we would accept it using rhosts authentication. */
|
||||||
if (!auth_rhosts(pw, client_user))
|
if (!auth_rhosts(pw, client_user))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
canonical_hostname = get_canonical_hostname();
|
canonical_hostname = get_canonical_hostname();
|
||||||
|
|
||||||
debug("Rhosts RSA authentication: canonical host %.900s",
|
debug("Rhosts RSA authentication: canonical host %.900s", canonical_hostname);
|
||||||
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. */
|
/* 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,
|
host_status = check_host_in_hostfile(SSH_SYSTEM_HOSTFILE, canonical_hostname,
|
||||||
client_host_key_e, client_host_key_n,
|
client_key, found);
|
||||||
ke, kn);
|
|
||||||
|
|
||||||
/* Check user host file unless ignored. */
|
/* Check user host file unless ignored. */
|
||||||
if (host_status != HOST_OK && !options.ignore_user_known_hosts) {
|
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() */
|
/* XXX race between stat and the following open() */
|
||||||
temporarily_use_uid(pw->pw_uid);
|
temporarily_use_uid(pw->pw_uid);
|
||||||
host_status = check_host_in_hostfile(user_hostfile, canonical_hostname,
|
host_status = check_host_in_hostfile(user_hostfile, canonical_hostname,
|
||||||
client_host_key_e, client_host_key_n,
|
client_key, found);
|
||||||
ke, kn);
|
|
||||||
restore_uid();
|
restore_uid();
|
||||||
}
|
}
|
||||||
xfree(user_hostfile);
|
xfree(user_hostfile);
|
||||||
}
|
}
|
||||||
BN_free(ke);
|
key_free(client_key);
|
||||||
BN_free(kn);
|
key_free(found);
|
||||||
|
|
||||||
if (host_status != HOST_OK) {
|
if (host_status != HOST_OK) {
|
||||||
debug("Rhosts with RSA host authentication denied: unknown or invalid host key");
|
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. */
|
/* A matching host key was found and is known. */
|
||||||
|
|
||||||
/* Perform the challenge-response dialog with the client for the host key. */
|
/* 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.",
|
log("Client on %.800s failed to respond correctly to host authentication.",
|
||||||
canonical_hostname);
|
canonical_hostname);
|
||||||
return 0;
|
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.",
|
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.");
|
packet_send_debug("Rhosts with RSA host authentication accepted.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "rsa.h"
|
||||||
#include "packet.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 "ssh.h"
|
||||||
#include "mpaux.h"
|
#include "mpaux.h"
|
||||||
#include "uidswap.h"
|
#include "uidswap.h"
|
||||||
|
#include "match.h"
|
||||||
#include "servconf.h"
|
#include "servconf.h"
|
||||||
|
|
||||||
#include <ssl/rsa.h>
|
#include <ssl/rsa.h>
|
||||||
@ -60,10 +61,9 @@ extern unsigned char session_id[16];
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
auth_rsa_challenge_dialog(BIGNUM *e, BIGNUM *n)
|
auth_rsa_challenge_dialog(RSA *pk)
|
||||||
{
|
{
|
||||||
BIGNUM *challenge, *encrypted_challenge;
|
BIGNUM *challenge, *encrypted_challenge;
|
||||||
RSA *pk;
|
|
||||||
BN_CTX *ctx;
|
BN_CTX *ctx;
|
||||||
unsigned char buf[32], mdbuf[16], response[16];
|
unsigned char buf[32], mdbuf[16], response[16];
|
||||||
MD5_CTX md;
|
MD5_CTX md;
|
||||||
@ -76,19 +76,11 @@ auth_rsa_challenge_dialog(BIGNUM *e, BIGNUM *n)
|
|||||||
/* Generate a random challenge. */
|
/* Generate a random challenge. */
|
||||||
BN_rand(challenge, 256, 0, 0);
|
BN_rand(challenge, 256, 0, 0);
|
||||||
ctx = BN_CTX_new();
|
ctx = BN_CTX_new();
|
||||||
BN_mod(challenge, challenge, n, ctx);
|
BN_mod(challenge, challenge, pk->n, ctx);
|
||||||
BN_CTX_free(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. */
|
/* Encrypt the challenge with the public key. */
|
||||||
rsa_public_encrypt(encrypted_challenge, challenge, pk);
|
rsa_public_encrypt(encrypted_challenge, challenge, pk);
|
||||||
RSA_free(pk);
|
|
||||||
|
|
||||||
/* Send the encrypted challenge to the client. */
|
/* Send the encrypted challenge to the client. */
|
||||||
packet_start(SSH_SMSG_AUTH_RSA_CHALLENGE);
|
packet_start(SSH_SMSG_AUTH_RSA_CHALLENGE);
|
||||||
@ -140,7 +132,7 @@ auth_rsa(struct passwd *pw, BIGNUM *client_n)
|
|||||||
FILE *f;
|
FILE *f;
|
||||||
unsigned long linenum = 0;
|
unsigned long linenum = 0;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
BIGNUM *e, *n;
|
RSA *pk;
|
||||||
|
|
||||||
/* Temporarily use the user's uid. */
|
/* Temporarily use the user's uid. */
|
||||||
temporarily_use_uid(pw->pw_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. */
|
/* Flag indicating whether authentication has succeeded. */
|
||||||
authenticated = 0;
|
authenticated = 0;
|
||||||
|
|
||||||
e = BN_new();
|
pk = RSA_new();
|
||||||
n = BN_new();
|
pk->e = BN_new();
|
||||||
|
pk->n = BN_new();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Go though the accepted keys, looking for the current key. If
|
* 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;
|
options = NULL;
|
||||||
|
|
||||||
/* Parse the key from the line. */
|
/* 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",
|
debug("%.100s, line %lu: bad key syntax",
|
||||||
SSH_USER_PERMITTED_KEYS, linenum);
|
SSH_USER_PERMITTED_KEYS, linenum);
|
||||||
packet_send_debug("%.100s, line %lu: bad key syntax",
|
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. */
|
/* cp now points to the comment part. */
|
||||||
|
|
||||||
/* Check if the we have found the desired key (identified by its modulus). */
|
/* 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;
|
continue;
|
||||||
|
|
||||||
/* check the real bits */
|
/* check the real bits */
|
||||||
if (bits != BN_num_bits(n))
|
if (bits != BN_num_bits(pk->n))
|
||||||
log("Warning: %s, line %ld: keysize mismatch: "
|
log("Warning: %s, line %ld: keysize mismatch: "
|
||||||
"actual %d vs. announced %d.",
|
"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. */
|
/* We have found the desired key. */
|
||||||
|
|
||||||
|
|
||||||
/* Perform the challenge-response dialog for this key. */
|
/* Perform the challenge-response dialog for this key. */
|
||||||
if (!auth_rsa_challenge_dialog(e, n)) {
|
if (!auth_rsa_challenge_dialog(pk)) {
|
||||||
/* Wrong response. */
|
/* Wrong response. */
|
||||||
verbose("Wrong response to RSA authentication challenge.");
|
verbose("Wrong response to RSA authentication challenge.");
|
||||||
packet_send_debug("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. */
|
/* Close the file. */
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
BN_clear_free(n);
|
RSA_free(pk);
|
||||||
BN_clear_free(e);
|
|
||||||
|
|
||||||
if (authenticated)
|
if (authenticated)
|
||||||
packet_send_debug("RSA authentication accepted.");
|
packet_send_debug("RSA authentication accepted.");
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "ssh.h"
|
||||||
#include <ssl/bn.h>
|
#include <ssl/bn.h>
|
||||||
@ -32,7 +32,7 @@ buffer_put_bignum(Buffer *buffer, BIGNUM *value)
|
|||||||
{
|
{
|
||||||
int bits = BN_num_bits(value);
|
int bits = BN_num_bits(value);
|
||||||
int bin_size = (bits + 7) / 8;
|
int bin_size = (bits + 7) / 8;
|
||||||
char *buf = xmalloc(bin_size);
|
char unsigned *buf = xmalloc(bin_size);
|
||||||
int oi;
|
int oi;
|
||||||
char msg[2];
|
char msg[2];
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ buffer_put_bignum(Buffer *buffer, BIGNUM *value)
|
|||||||
PUT_16BIT(msg, bits);
|
PUT_16BIT(msg, bits);
|
||||||
buffer_append(buffer, msg, 2);
|
buffer_append(buffer, msg, 2);
|
||||||
/* Store the binary data. */
|
/* Store the binary data. */
|
||||||
buffer_append(buffer, buf, oi);
|
buffer_append(buffer, (char *)buf, oi);
|
||||||
|
|
||||||
memset(buf, 0, bin_size);
|
memset(buf, 0, bin_size);
|
||||||
xfree(buf);
|
xfree(buf);
|
||||||
@ -68,7 +68,7 @@ buffer_get_bignum(Buffer *buffer, BIGNUM *value)
|
|||||||
bytes = (bits + 7) / 8;
|
bytes = (bits + 7) / 8;
|
||||||
if (buffer_len(buffer) < bytes)
|
if (buffer_len(buffer) < bytes)
|
||||||
fatal("buffer_get_bignum: input buffer too small");
|
fatal("buffer_get_bignum: input buffer too small");
|
||||||
bin = buffer_ptr(buffer);
|
bin = (unsigned char*) buffer_ptr(buffer);
|
||||||
BN_bin2bn(bin, bytes, value);
|
BN_bin2bn(bin, bytes, value);
|
||||||
buffer_consume(buffer, bytes);
|
buffer_consume(buffer, bytes);
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "ssh.h"
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
@ -1037,7 +1037,7 @@ channel_input_port_open(int payload_len)
|
|||||||
int remote_channel, sock = 0, newch, i;
|
int remote_channel, sock = 0, newch, i;
|
||||||
u_short host_port;
|
u_short host_port;
|
||||||
char *host, *originator_string;
|
char *host, *originator_string;
|
||||||
int host_len, originator_len;
|
unsigned int host_len, originator_len;
|
||||||
struct addrinfo hints, *ai, *aitop;
|
struct addrinfo hints, *ai, *aitop;
|
||||||
char ntop[NI_MAXHOST], strport[NI_MAXSERV];
|
char ntop[NI_MAXHOST], strport[NI_MAXSERV];
|
||||||
int gaierr;
|
int gaierr;
|
||||||
@ -1284,7 +1284,7 @@ x11_input_open(int payload_len)
|
|||||||
int remote_channel, display_number, sock = 0, newch;
|
int remote_channel, display_number, sock = 0, newch;
|
||||||
const char *display;
|
const char *display;
|
||||||
char buf[1024], *cp, *remote_host;
|
char buf[1024], *cp, *remote_host;
|
||||||
int remote_len;
|
unsigned int remote_len;
|
||||||
struct addrinfo hints, *ai, *aitop;
|
struct addrinfo hints, *ai, *aitop;
|
||||||
char strport[NI_MAXSERV];
|
char strport[NI_MAXSERV];
|
||||||
int gaierr;
|
int gaierr;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "ssh.h"
|
||||||
#include "cipher.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.
|
* Names of all encryption algorithms.
|
||||||
* These must match the numbers defined in cipher.h.
|
* These must match the numbers defined in cipher.h.
|
||||||
@ -298,7 +286,6 @@ cipher_decrypt(CipherContext *context, unsigned char *dest,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SSH_CIPHER_3DES:
|
case SSH_CIPHER_3DES:
|
||||||
/* CRC-32 attack? */
|
|
||||||
SSH_3CBC_DECRYPT(context->u.des3.key1,
|
SSH_3CBC_DECRYPT(context->u.des3.key1,
|
||||||
context->u.des3.key2, &context->u.des3.iv2,
|
context->u.des3.key2, &context->u.des3.iv2,
|
||||||
context->u.des3.key3, &context->u.des3.iv3,
|
context->u.des3.key3, &context->u.des3.iv3,
|
||||||
@ -306,7 +293,6 @@ cipher_decrypt(CipherContext *context, unsigned char *dest,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SSH_CIPHER_BLOWFISH:
|
case SSH_CIPHER_BLOWFISH:
|
||||||
detect_cbc_attack(src, len);
|
|
||||||
swap_bytes(src, dest, len);
|
swap_bytes(src, dest, len);
|
||||||
BF_cbc_encrypt((void *) dest, dest, len,
|
BF_cbc_encrypt((void *) dest, dest, len,
|
||||||
&context->u.bf.key, context->u.bf.iv,
|
&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
|
#ifndef CIPHER_H
|
||||||
#define CIPHER_H
|
#define CIPHER_H
|
||||||
@ -88,10 +88,4 @@ void
|
|||||||
cipher_decrypt(CipherContext * context, unsigned char *dest,
|
cipher_decrypt(CipherContext * context, unsigned char *dest,
|
||||||
const unsigned char *src, unsigned int len);
|
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 */
|
#endif /* CIPHER_H */
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "ssh.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
@ -75,13 +75,13 @@ buffer_compress(Buffer * input_buffer, Buffer * output_buffer)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Input is the contents of the input buffer. */
|
/* 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);
|
outgoing_stream.avail_in = buffer_len(input_buffer);
|
||||||
|
|
||||||
/* Loop compressing until deflate() returns with avail_out != 0. */
|
/* Loop compressing until deflate() returns with avail_out != 0. */
|
||||||
do {
|
do {
|
||||||
/* Set up fixed-size output buffer. */
|
/* Set up fixed-size output buffer. */
|
||||||
outgoing_stream.next_out = buf;
|
outgoing_stream.next_out = (unsigned char *)buf;
|
||||||
outgoing_stream.avail_out = sizeof(buf);
|
outgoing_stream.avail_out = sizeof(buf);
|
||||||
|
|
||||||
/* Compress as much data into the buffer as possible. */
|
/* Compress as much data into the buffer as possible. */
|
||||||
@ -124,10 +124,10 @@ buffer_uncompress(Buffer * input_buffer, Buffer * output_buffer)
|
|||||||
char buf[4096];
|
char buf[4096];
|
||||||
int status;
|
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.avail_in = buffer_len(input_buffer);
|
||||||
|
|
||||||
incoming_stream.next_out = buf;
|
incoming_stream.next_out = (unsigned char *) buf;
|
||||||
incoming_stream.avail_out = sizeof(buf);
|
incoming_stream.avail_out = sizeof(buf);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -136,7 +136,7 @@ buffer_uncompress(Buffer * input_buffer, Buffer * output_buffer)
|
|||||||
case Z_OK:
|
case Z_OK:
|
||||||
buffer_append(output_buffer, buf,
|
buffer_append(output_buffer, buf,
|
||||||
sizeof(buf) - incoming_stream.avail_out);
|
sizeof(buf) - incoming_stream.avail_out);
|
||||||
incoming_stream.next_out = buf;
|
incoming_stream.next_out = (unsigned char *) buf;
|
||||||
incoming_stream.avail_out = sizeof(buf);
|
incoming_stream.avail_out = sizeof(buf);
|
||||||
break;
|
break;
|
||||||
case Z_STREAM_END:
|
case Z_STREAM_END:
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "ssh.h"
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
@ -46,7 +46,7 @@ fingerprint(BIGNUM *e, BIGNUM *n)
|
|||||||
static char retval[80];
|
static char retval[80];
|
||||||
MD5_CTX md;
|
MD5_CTX md;
|
||||||
unsigned char d[16];
|
unsigned char d[16];
|
||||||
char *buf;
|
unsigned char *buf;
|
||||||
int nlen, elen;
|
int nlen, elen;
|
||||||
|
|
||||||
nlen = BN_num_bytes(n);
|
nlen = BN_num_bytes(n);
|
||||||
|
@ -14,63 +14,23 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "packet.h"
|
||||||
|
#include "match.h"
|
||||||
#include "ssh.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
|
* Parses an RSA (number of bits, e, n) or DSA key from a string. Moves the
|
||||||
* the pointer. The integer must already be initialized. This function is
|
* pointer over the key. Skips any whitespace at the beginning and at end.
|
||||||
* 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
|
int
|
||||||
auth_rsa_read_bignum(char **cpp, BIGNUM * value)
|
hostfile_read_key(char **cpp, unsigned int *bitsp, Key *ret)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
unsigned int bits;
|
unsigned int bits;
|
||||||
char *cp;
|
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++)
|
for (bits = 0; *cp >= '0' && *cp <= '9'; cp++)
|
||||||
bits = 10 * bits + *cp - '0';
|
bits = 10 * bits + *cp - '0';
|
||||||
|
|
||||||
/* Get public exponent. */
|
if (!key_read(ret, bits, &cp))
|
||||||
if (!auth_rsa_read_bignum(&cp, e))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Get public modulus. */
|
|
||||||
if (!auth_rsa_read_bignum(&cp, n))
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Skip trailing whitespace. */
|
/* Skip trailing whitespace. */
|
||||||
@ -103,63 +58,30 @@ auth_rsa_read_key(char **cpp, unsigned int *bitsp, BIGNUM * e, BIGNUM * n)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int
|
||||||
* Tries to match the host name (which must be in all lowercase) against the
|
auth_rsa_read_key(char **cpp, unsigned int *bitsp, BIGNUM * e, BIGNUM * n)
|
||||||
* comma-separated sequence of subpatterns (each possibly preceded by ! to
|
{
|
||||||
* indicate negation). Returns true if there is a positive match; zero
|
Key *k = key_new(KEY_RSA);
|
||||||
* otherwise.
|
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
|
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];
|
if (key == NULL || key->type != KEY_RSA || key->rsa == NULL)
|
||||||
int negated;
|
return 1;
|
||||||
int got_positive;
|
if (bits != BN_num_bits(key->rsa->n)) {
|
||||||
unsigned int i, subi;
|
error("Warning: %s, line %d: keysize mismatch for host %s: "
|
||||||
|
"actual %d vs. announced %d.",
|
||||||
got_positive = 0;
|
filename, linenum, host, BN_num_bits(key->rsa->n), bits);
|
||||||
for (i = 0; i < len;) {
|
error("Warning: replace %d with %d in %s, line %d.",
|
||||||
/* Check if the subpattern is negated. */
|
bits, BN_num_bits(key->rsa->n), filename, linenum);
|
||||||
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 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -170,8 +92,7 @@ match_hostname(const char *host, const char *pattern, unsigned int len)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
HostStatus
|
HostStatus
|
||||||
check_host_in_hostfile(const char *filename, const char *host,
|
check_host_in_hostfile(const char *filename, const char *host, Key *key, Key *found)
|
||||||
BIGNUM * e, BIGNUM * n, BIGNUM * ke, BIGNUM * kn)
|
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char line[8192];
|
char line[8192];
|
||||||
@ -180,6 +101,8 @@ check_host_in_hostfile(const char *filename, const char *host,
|
|||||||
char *cp, *cp2;
|
char *cp, *cp2;
|
||||||
HostStatus end_return;
|
HostStatus end_return;
|
||||||
|
|
||||||
|
if (key == NULL)
|
||||||
|
fatal("no key to look up");
|
||||||
/* Open the file containing the list of known hosts. */
|
/* Open the file containing the list of known hosts. */
|
||||||
f = fopen(filename, "r");
|
f = fopen(filename, "r");
|
||||||
if (!f)
|
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
|
* Extract the key from the line. This will skip any leading
|
||||||
* whitespace. Ignore badly formatted lines.
|
* 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;
|
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. */
|
/* 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. */
|
/* Ok, they match. */
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return HOST_OK;
|
return HOST_OK;
|
||||||
@ -260,41 +178,28 @@ check_host_in_hostfile(const char *filename, const char *host,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
add_host_to_hostfile(const char *filename, const char *host,
|
add_host_to_hostfile(const char *filename, const char *host, Key *key)
|
||||||
BIGNUM * e, BIGNUM * n)
|
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char *buf;
|
int success = 0;
|
||||||
unsigned int bits;
|
|
||||||
|
if (key == NULL)
|
||||||
|
return 1;
|
||||||
|
|
||||||
/* Open the file for appending. */
|
/* Open the file for appending. */
|
||||||
f = fopen(filename, "a");
|
f = fopen(filename, "a");
|
||||||
if (!f)
|
if (!f)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* size of modulus 'n' */
|
fprintf(f, "%s ", host);
|
||||||
bits = BN_num_bits(n);
|
if (key_write(key, f)) {
|
||||||
|
fprintf(f, "\n");
|
||||||
/* Print the host name and key to the file. */
|
success = 1;
|
||||||
fprintf(f, "%s %u ", host, bits);
|
} else {
|
||||||
buf = BN_bn2dec(e);
|
error("add_host_to_hostfile: saving key failed");
|
||||||
if (buf == NULL) {
|
|
||||||
error("add_host_to_hostfile: BN_bn2dec(e) failed");
|
|
||||||
fclose(f);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
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. */
|
/* Close the file. */
|
||||||
fclose(f);
|
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 \
|
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 \
|
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 \
|
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
|
NOPROFILE= yes
|
||||||
NOPIC= yes
|
NOPIC= yes
|
||||||
@ -15,7 +16,7 @@ install:
|
|||||||
.include <bsd.own.mk>
|
.include <bsd.own.mk>
|
||||||
|
|
||||||
.if (${KERBEROS} == "yes")
|
.if (${KERBEROS} == "yes")
|
||||||
CFLAGS+= -DKRB4 -I/usr/include/kerberosIV
|
CFLAGS+= -DKRB4 -I${DESTDIR}/usr/include/kerberosIV
|
||||||
.if (${AFS} == "yes")
|
.if (${AFS} == "yes")
|
||||||
CFLAGS+= -DAFS
|
CFLAGS+= -DAFS
|
||||||
SRCS+= radix.c
|
SRCS+= radix.c
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "xmalloc.h"
|
||||||
#include "ssh.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
|
void
|
||||||
do_log(LogLevel level, const char *fmt, va_list args)
|
do_log(LogLevel level, const char *fmt, va_list args)
|
||||||
{
|
{
|
||||||
char msgbuf[MSGBUFSIZE];
|
char msgbuf[MSGBUFSIZ];
|
||||||
|
|
||||||
if (level > log_level)
|
if (level > log_level)
|
||||||
return;
|
return;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 <syslog.h>
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
@ -91,13 +91,13 @@ log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr)
|
|||||||
log_on_stderr = on_stderr;
|
log_on_stderr = on_stderr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MSGBUFSIZE 1024
|
#define MSGBUFSIZ 1024
|
||||||
|
|
||||||
void
|
void
|
||||||
do_log(LogLevel level, const char *fmt, va_list args)
|
do_log(LogLevel level, const char *fmt, va_list args)
|
||||||
{
|
{
|
||||||
char msgbuf[MSGBUFSIZE];
|
char msgbuf[MSGBUFSIZ];
|
||||||
char fmtbuf[MSGBUFSIZE];
|
char fmtbuf[MSGBUFSIZ];
|
||||||
char *txt = NULL;
|
char *txt = NULL;
|
||||||
int pri = LOG_INFO;
|
int pri = LOG_INFO;
|
||||||
extern char *__progname;
|
extern char *__progname;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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"
|
#include "ssh.h"
|
||||||
|
|
||||||
@ -80,3 +80,62 @@ match_pattern(const char *s, const char *pattern)
|
|||||||
}
|
}
|
||||||
/* NOTREACHED */
|
/* 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
|
#ifndef PACKET_H
|
||||||
#define 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
|
* The error message should not contain a newline. The total length of the
|
||||||
* message must not exceed 1024 bytes.
|
* 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
|
* 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,
|
* remote side protocol flags do not indicate that it supports SSH_MSG_DEBUG,
|
||||||
* this will do nothing.
|
* 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. */
|
/* Checks if there is any buffered output, and tries to write some of the output. */
|
||||||
void packet_write_poll(void);
|
void packet_write_poll(void);
|
||||||
|
@ -213,7 +213,7 @@ creds_to_radix(CREDENTIALS *creds, unsigned char *buf)
|
|||||||
p += creds->ticket_st.length;
|
p += creds->ticket_st.length;
|
||||||
len = p - temp;
|
len = p - temp;
|
||||||
|
|
||||||
return (uuencode(temp, len, buf));
|
return (uuencode((unsigned char *)temp, len, (char *)buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -225,7 +225,7 @@ radix_to_creds(const char *buf, CREDENTIALS *creds)
|
|||||||
char version;
|
char version;
|
||||||
char temp[2048];
|
char temp[2048];
|
||||||
|
|
||||||
if (!(len = uudecode(buf, temp, sizeof(temp))))
|
if (!(len = uudecode(buf, (unsigned char *)temp, sizeof(temp))))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
p = temp;
|
p = temp;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "ssh.h"
|
||||||
#include "cipher.h"
|
#include "cipher.h"
|
||||||
@ -638,7 +638,7 @@ fill_default_options(Options * options)
|
|||||||
if (options->forward_agent == -1)
|
if (options->forward_agent == -1)
|
||||||
options->forward_agent = 1;
|
options->forward_agent = 1;
|
||||||
if (options->forward_x11 == -1)
|
if (options->forward_x11 == -1)
|
||||||
options->forward_x11 = 1;
|
options->forward_x11 = 0;
|
||||||
if (options->gateway_ports == -1)
|
if (options->gateway_ports == -1)
|
||||||
options->gateway_ports = 0;
|
options->gateway_ports = 0;
|
||||||
if (options->use_privileged_port == -1)
|
if (options->use_privileged_port == -1)
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "rsa.h"
|
||||||
#include "ssh.h"
|
#include "ssh.h"
|
||||||
@ -110,7 +110,7 @@ rsa_generate_key(RSA *prv, RSA *pub, unsigned int bits)
|
|||||||
void
|
void
|
||||||
rsa_public_encrypt(BIGNUM *out, BIGNUM *in, RSA *key)
|
rsa_public_encrypt(BIGNUM *out, BIGNUM *in, RSA *key)
|
||||||
{
|
{
|
||||||
char *inbuf, *outbuf;
|
unsigned char *inbuf, *outbuf;
|
||||||
int len, ilen, olen;
|
int len, ilen, olen;
|
||||||
|
|
||||||
if (BN_num_bits(key->e) < 2 || !BN_is_odd(key->e))
|
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
|
void
|
||||||
rsa_private_decrypt(BIGNUM *out, BIGNUM *in, RSA *key)
|
rsa_private_decrypt(BIGNUM *out, BIGNUM *in, RSA *key)
|
||||||
{
|
{
|
||||||
char *inbuf, *outbuf;
|
unsigned char *inbuf, *outbuf;
|
||||||
int len, ilen, olen;
|
int len, ilen, olen;
|
||||||
|
|
||||||
olen = BN_num_bytes(key->n);
|
olen = BN_num_bytes(key->n);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" Created: Sun May 7 00:14:37 1995 ylo
|
.\" 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
|
.Dd September 25, 1999
|
||||||
.Dt SCP 1
|
.Dt SCP 1
|
||||||
@ -38,7 +38,8 @@
|
|||||||
.Sm on
|
.Sm on
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm
|
.Nm
|
||||||
copies files between hosts on a network. It uses
|
copies files between hosts on a network.
|
||||||
|
It uses
|
||||||
.Xr ssh 1
|
.Xr ssh 1
|
||||||
for data transfer, and uses the same authentication and provides the
|
for data transfer, and uses the same authentication and provides the
|
||||||
same security as
|
same security as
|
||||||
@ -50,18 +51,19 @@ will ask for passwords or passphrases if they are needed for
|
|||||||
authentication.
|
authentication.
|
||||||
.Pp
|
.Pp
|
||||||
Any file name may contain a host and user specification to indicate
|
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
|
that the file is to be copied to/from that host.
|
||||||
remote hosts are permitted.
|
Copies between two remote hosts are permitted.
|
||||||
.Pp
|
.Pp
|
||||||
The options are as follows:
|
The options are as follows:
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Fl c Ar cipher
|
.It Fl c Ar cipher
|
||||||
Selects the cipher to use for encrypting the data transfer. This
|
Selects the cipher to use for encrypting the data transfer.
|
||||||
option is directly passed to
|
This option is directly passed to
|
||||||
.Xr ssh 1 .
|
.Xr ssh 1 .
|
||||||
.It Fl i Ar identity_file
|
.It Fl i Ar identity_file
|
||||||
Selects the file from which the identity (private key) for RSA
|
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 .
|
.Xr ssh 1 .
|
||||||
.It Fl p
|
.It Fl p
|
||||||
Preserves modification times, access times, and modes from the
|
Preserves modification times, access times, and modes from the
|
||||||
@ -69,25 +71,28 @@ original file.
|
|||||||
.It Fl r
|
.It Fl r
|
||||||
Recursively copy entire directories.
|
Recursively copy entire directories.
|
||||||
.It Fl v
|
.It Fl v
|
||||||
Verbose mode. Causes
|
Verbose mode.
|
||||||
|
Causes
|
||||||
.Nm
|
.Nm
|
||||||
and
|
and
|
||||||
.Xr ssh 1
|
.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.
|
debugging connection, authentication, and configuration problems.
|
||||||
.It Fl B
|
.It Fl B
|
||||||
Selects batch mode (prevents asking for passwords or passphrases).
|
Selects batch mode (prevents asking for passwords or passphrases).
|
||||||
.It Fl q
|
.It Fl q
|
||||||
Disables the progress meter.
|
Disables the progress meter.
|
||||||
.It Fl C
|
.It Fl C
|
||||||
Compression enable. Passes the
|
Compression enable.
|
||||||
|
Passes the
|
||||||
.Fl C
|
.Fl C
|
||||||
flag to
|
flag to
|
||||||
.Xr ssh 1
|
.Xr ssh 1
|
||||||
to enable compression.
|
to enable compression.
|
||||||
.It Fl P Ar port
|
.It Fl P Ar port
|
||||||
Specifies the port to connect to on the remote host. Note that this
|
Specifies the port to connect to on the remote host.
|
||||||
option is written with a capital
|
Note that this option is written with a capital
|
||||||
.Sq P ,
|
.Sq P ,
|
||||||
because
|
because
|
||||||
.Fl p
|
.Fl p
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "ssh.h"
|
||||||
#include "xmalloc.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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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 *
|
char *
|
||||||
@ -1118,7 +1118,7 @@ alarmtimer(int wait)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
updateprogressmeter(void)
|
updateprogressmeter(int ignore)
|
||||||
{
|
{
|
||||||
int save_errno = errno;
|
int save_errno = errno;
|
||||||
|
|
||||||
@ -1224,7 +1224,7 @@ progressmeter(int flag)
|
|||||||
atomicio(write, fileno(stdout), buf, strlen(buf));
|
atomicio(write, fileno(stdout), buf, strlen(buf));
|
||||||
|
|
||||||
if (flag == -1) {
|
if (flag == -1) {
|
||||||
signal(SIGALRM, (void *) updateprogressmeter);
|
signal(SIGALRM, updateprogressmeter);
|
||||||
alarmtimer(1);
|
alarmtimer(1);
|
||||||
} else if (flag == 1) {
|
} else if (flag == 1) {
|
||||||
alarmtimer(0);
|
alarmtimer(0);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "ssh.h"
|
||||||
#include "servconf.h"
|
#include "servconf.h"
|
||||||
@ -87,7 +87,7 @@ fill_default_server_options(ServerOptions *options)
|
|||||||
if (options->permit_root_login == -1)
|
if (options->permit_root_login == -1)
|
||||||
options->permit_root_login = 1; /* yes */
|
options->permit_root_login = 1; /* yes */
|
||||||
if (options->ignore_rhosts == -1)
|
if (options->ignore_rhosts == -1)
|
||||||
options->ignore_rhosts = 0;
|
options->ignore_rhosts = 1;
|
||||||
if (options->ignore_user_known_hosts == -1)
|
if (options->ignore_user_known_hosts == -1)
|
||||||
options->ignore_user_known_hosts = 0;
|
options->ignore_user_known_hosts = 0;
|
||||||
if (options->check_mail == -1)
|
if (options->check_mail == -1)
|
||||||
@ -95,9 +95,9 @@ fill_default_server_options(ServerOptions *options)
|
|||||||
if (options->print_motd == -1)
|
if (options->print_motd == -1)
|
||||||
options->print_motd = 1;
|
options->print_motd = 1;
|
||||||
if (options->x11_forwarding == -1)
|
if (options->x11_forwarding == -1)
|
||||||
options->x11_forwarding = 1;
|
options->x11_forwarding = 0;
|
||||||
if (options->x11_display_offset == -1)
|
if (options->x11_display_offset == -1)
|
||||||
options->x11_display_offset = 1;
|
options->x11_display_offset = 10;
|
||||||
if (options->strict_modes == -1)
|
if (options->strict_modes == -1)
|
||||||
options->strict_modes = 1;
|
options->strict_modes = 1;
|
||||||
if (options->keepalives == -1)
|
if (options->keepalives == -1)
|
||||||
@ -109,7 +109,7 @@ fill_default_server_options(ServerOptions *options)
|
|||||||
if (options->rhosts_authentication == -1)
|
if (options->rhosts_authentication == -1)
|
||||||
options->rhosts_authentication = 0;
|
options->rhosts_authentication = 0;
|
||||||
if (options->rhosts_rsa_authentication == -1)
|
if (options->rhosts_rsa_authentication == -1)
|
||||||
options->rhosts_rsa_authentication = 1;
|
options->rhosts_rsa_authentication = 0;
|
||||||
if (options->rsa_authentication == -1)
|
if (options->rsa_authentication == -1)
|
||||||
options->rsa_authentication = 1;
|
options->rsa_authentication = 1;
|
||||||
#ifdef KRB4
|
#ifdef KRB4
|
||||||
@ -133,7 +133,7 @@ fill_default_server_options(ServerOptions *options)
|
|||||||
options->skey_authentication = 1;
|
options->skey_authentication = 1;
|
||||||
#endif
|
#endif
|
||||||
if (options->permit_empty_passwd == -1)
|
if (options->permit_empty_passwd == -1)
|
||||||
options->permit_empty_passwd = 1;
|
options->permit_empty_passwd = 0;
|
||||||
if (options->use_login == -1)
|
if (options->use_login == -1)
|
||||||
options->use_login = 0;
|
options->use_login = 0;
|
||||||
}
|
}
|
||||||
@ -402,7 +402,7 @@ parse_flag:
|
|||||||
|
|
||||||
case sIgnoreUserKnownHosts:
|
case sIgnoreUserKnownHosts:
|
||||||
intptr = &options->ignore_user_known_hosts;
|
intptr = &options->ignore_user_known_hosts;
|
||||||
goto parse_int;
|
goto parse_flag;
|
||||||
|
|
||||||
case sRhostsAuthentication:
|
case sRhostsAuthentication:
|
||||||
intptr = &options->rhosts_authentication;
|
intptr = &options->rhosts_authentication;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" Created: Sat Apr 22 23:55:14 1995 ylo
|
.\" 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
|
.Dd September 25, 1999
|
||||||
.Dt SSH-ADD 1
|
.Dt SSH-ADD 1
|
||||||
@ -27,11 +27,11 @@ adds identities to the authentication agent,
|
|||||||
.Xr ssh-agent 1 .
|
.Xr ssh-agent 1 .
|
||||||
When run without arguments, it adds the file
|
When run without arguments, it adds the file
|
||||||
.Pa $HOME/.ssh/identity .
|
.Pa $HOME/.ssh/identity .
|
||||||
Alternative file names can be given on the
|
Alternative file names can be given on the command line.
|
||||||
command line. If any file requires a passphrase,
|
If any file requires a passphrase,
|
||||||
.Nm
|
.Nm
|
||||||
asks for the passphrase from the user.
|
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
|
.Pp
|
||||||
The authentication agent must be running and must be an ancestor of
|
The authentication agent must be running and must be an ancestor of
|
||||||
the current process for
|
the current process for
|
||||||
@ -52,15 +52,15 @@ Deletes all identities from the agent.
|
|||||||
.Sh FILES
|
.Sh FILES
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Pa $HOME/.ssh/identity
|
.It Pa $HOME/.ssh/identity
|
||||||
Contains the RSA authentication identity of the user. This file
|
Contains the RSA authentication identity of the user.
|
||||||
should not be readable by anyone but the user.
|
This file should not be readable by anyone but the user.
|
||||||
Note that
|
Note that
|
||||||
.Nm
|
.Nm
|
||||||
ignores this file if it is accessible by others.
|
ignores this file if it is accessible by others.
|
||||||
It is possible to
|
It is possible to
|
||||||
specify a passphrase when generating the key; that passphrase will be
|
specify a passphrase when generating the key; that passphrase will be
|
||||||
used to encrypt the private part of this file. This is the
|
used to encrypt the private part of this file.
|
||||||
default file added by
|
This is the default file added by
|
||||||
.Nm
|
.Nm
|
||||||
when no other files have been specified.
|
when no other files have been specified.
|
||||||
.Pp
|
.Pp
|
||||||
@ -70,7 +70,8 @@ when no other files have been specified.
|
|||||||
If
|
If
|
||||||
.Nm
|
.Nm
|
||||||
needs a passphrase, it will read the passphrase from the current
|
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
|
.Nm
|
||||||
does not have a terminal associated with it but
|
does not have a terminal associated with it but
|
||||||
.Ev DISPLAY
|
.Ev DISPLAY
|
||||||
@ -78,12 +79,13 @@ and
|
|||||||
.Ev SSH_ASKPASS
|
.Ev SSH_ASKPASS
|
||||||
are set, it will execute the program specified by
|
are set, it will execute the program specified by
|
||||||
.Ev SSH_ASKPASS
|
.Ev SSH_ASKPASS
|
||||||
and open an X11 window to read the passphrase. This is particularly
|
and open an X11 window to read the passphrase.
|
||||||
useful when calling
|
This is particularly useful when calling
|
||||||
.Nm
|
.Nm
|
||||||
from a
|
from a
|
||||||
.Pa .Xsession
|
.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
|
may be necessary to redirect the input from
|
||||||
.Pa /dev/null
|
.Pa /dev/null
|
||||||
to make this work.)
|
to make this work.)
|
||||||
@ -92,9 +94,10 @@ Tatu Ylonen <ylo@cs.hut.fi>
|
|||||||
.Pp
|
.Pp
|
||||||
OpenSSH
|
OpenSSH
|
||||||
is a derivative of the original (free) ssh 1.2.12 release, but with bugs
|
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,
|
removed and newer features re-added.
|
||||||
newer versions bore successively more restrictive licenses. This version
|
Rapidly after the 1.2.12 release,
|
||||||
of OpenSSH
|
newer versions bore successively more restrictive licenses.
|
||||||
|
This version of OpenSSH
|
||||||
.Bl -bullet
|
.Bl -bullet
|
||||||
.It
|
.It
|
||||||
has all components of a restrictive nature (i.e., patents, see
|
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 -*-
|
.\" -*- nroff -*-
|
||||||
.\"
|
.\"
|
||||||
@ -27,12 +27,13 @@
|
|||||||
.Oc
|
.Oc
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm
|
.Nm
|
||||||
is a program to hold authentication private keys. The
|
is a program to hold authentication private keys.
|
||||||
idea is that
|
The idea is that
|
||||||
.Nm
|
.Nm
|
||||||
is started in the beginning of an X-session or a login session, and
|
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
|
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
|
and automatically used for RSA authentication when logging in to other
|
||||||
machines using
|
machines using
|
||||||
.Xr ssh 1 .
|
.Xr ssh 1 .
|
||||||
@ -60,30 +61,34 @@ environment variable).
|
|||||||
If a commandline is given, this is executed as a subprocess of the agent.
|
If a commandline is given, this is executed as a subprocess of the agent.
|
||||||
When the command dies, so does the agent.
|
When the command dies, so does the agent.
|
||||||
.Pp
|
.Pp
|
||||||
The agent initially does not have any private keys. Keys are added
|
The agent initially does not have any private keys.
|
||||||
using
|
Keys are added using
|
||||||
.Xr ssh-add 1 .
|
.Xr ssh-add 1 .
|
||||||
When executed without arguments,
|
When executed without arguments,
|
||||||
.Xr ssh-add 1
|
.Xr ssh-add 1
|
||||||
adds the
|
adds the
|
||||||
.Pa $HOME/.ssh/identity
|
.Pa $HOME/.ssh/identity
|
||||||
file. If the identity has a passphrase,
|
file.
|
||||||
|
If the identity has a passphrase,
|
||||||
.Xr ssh-add 1
|
.Xr ssh-add 1
|
||||||
asks for the passphrase (using a small X11 application if running
|
asks for the passphrase (using a small X11 application if running
|
||||||
under X11, or from the terminal if running without X). It then sends
|
under X11, or from the terminal if running without X).
|
||||||
the identity to the agent. Several identities can be stored in the
|
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.
|
agent; the agent can automatically use any of these identities.
|
||||||
.Ic ssh-add -l
|
.Ic ssh-add -l
|
||||||
displays the identities currently held by the agent.
|
displays the identities currently held by the agent.
|
||||||
.Pp
|
.Pp
|
||||||
The idea is that the agent is run in the user's local PC, laptop, or
|
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.
|
machine, and authentication passphrases never go over the network.
|
||||||
However, the connection to the agent is forwarded over SSH
|
However, the connection to the agent is forwarded over SSH
|
||||||
remote logins, and the user can thus use the privileges given by the
|
remote logins, and the user can thus use the privileges given by the
|
||||||
identities anywhere in the network in a secure way.
|
identities anywhere in the network in a secure way.
|
||||||
.Pp
|
.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
|
start a new subcommand into which some environment variables are exported, or
|
||||||
you let the agent print the needed shell commands (either
|
you let the agent print the needed shell commands (either
|
||||||
.Xr sh 1
|
.Xr sh 1
|
||||||
@ -99,7 +104,8 @@ A unix-domain socket is created
|
|||||||
and the name of this socket is stored in the
|
and the name of this socket is stored in the
|
||||||
.Ev SSH_AUTH_SOCK
|
.Ev SSH_AUTH_SOCK
|
||||||
environment
|
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
|
This method is easily abused by root or another instance of the same
|
||||||
user.
|
user.
|
||||||
.Pp
|
.Pp
|
||||||
@ -112,28 +118,30 @@ line terminates.
|
|||||||
.Sh FILES
|
.Sh FILES
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Pa $HOME/.ssh/identity
|
.It Pa $HOME/.ssh/identity
|
||||||
Contains the RSA authentication identity of the user. This file
|
Contains the RSA authentication identity of the user.
|
||||||
should not be readable by anyone but the user. It is possible to
|
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
|
specify a passphrase when generating the key; that passphrase will be
|
||||||
used to encrypt the private part of this file. This file
|
used to encrypt the private part of this file.
|
||||||
is not used by
|
This file is not used by
|
||||||
.Nm
|
.Nm
|
||||||
but is normally added to the agent using
|
but is normally added to the agent using
|
||||||
.Xr ssh-add 1
|
.Xr ssh-add 1
|
||||||
at login time.
|
at login time.
|
||||||
.It Pa /tmp/ssh-XXXX/agent.<pid> ,
|
.It Pa /tmp/ssh-XXXX/agent.<pid> ,
|
||||||
Unix-domain sockets used to contain the connection to the
|
Unix-domain sockets used to contain the connection to the
|
||||||
authentication agent. These sockets should only be readable by the
|
authentication agent.
|
||||||
owner. The sockets should get automatically removed when the agent
|
These sockets should only be readable by the owner.
|
||||||
exits.
|
The sockets should get automatically removed when the agent exits.
|
||||||
.Sh AUTHOR
|
.Sh AUTHOR
|
||||||
Tatu Ylonen <ylo@cs.hut.fi>
|
Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
.Pp
|
.Pp
|
||||||
OpenSSH
|
OpenSSH
|
||||||
is a derivative of the original (free) ssh 1.2.12 release, but with bugs
|
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,
|
removed and newer features re-added.
|
||||||
newer versions bore successively more restrictive licenses. This version
|
Rapidly after the 1.2.12 release,
|
||||||
of OpenSSH
|
newer versions bore successively more restrictive licenses.
|
||||||
|
This version of OpenSSH
|
||||||
.Bl -bullet
|
.Bl -bullet
|
||||||
.It
|
.It
|
||||||
has all components of a restrictive nature (i.e., patents, see
|
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>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
@ -9,7 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "ssh.h"
|
||||||
#include "rsa.h"
|
#include "rsa.h"
|
||||||
@ -408,6 +408,7 @@ after_select(fd_set *readset, fd_set *writeset)
|
|||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int len, sock;
|
int len, sock;
|
||||||
|
socklen_t slen;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
struct sockaddr_un sunaddr;
|
struct sockaddr_un sunaddr;
|
||||||
|
|
||||||
@ -417,8 +418,8 @@ after_select(fd_set *readset, fd_set *writeset)
|
|||||||
break;
|
break;
|
||||||
case AUTH_SOCKET:
|
case AUTH_SOCKET:
|
||||||
if (FD_ISSET(sockets[i].fd, readset)) {
|
if (FD_ISSET(sockets[i].fd, readset)) {
|
||||||
len = sizeof(sunaddr);
|
slen = sizeof(sunaddr);
|
||||||
sock = accept(sockets[i].fd, (struct sockaddr *) & sunaddr, &len);
|
sock = accept(sockets[i].fd, (struct sockaddr *) & sunaddr, &slen);
|
||||||
if (sock < 0) {
|
if (sock < 0) {
|
||||||
perror("accept from AUTH_SOCKET");
|
perror("accept from AUTH_SOCKET");
|
||||||
break;
|
break;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" Created: Sat Apr 22 23:55:14 1995 ylo
|
.\" 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
|
.Dd September 25, 1999
|
||||||
.Dt SSH-KEYGEN 1
|
.Dt SSH-KEYGEN 1
|
||||||
@ -48,27 +48,31 @@ key in
|
|||||||
Additionally, the system administrator may use this to generate host keys.
|
Additionally, the system administrator may use this to generate host keys.
|
||||||
.Pp
|
.Pp
|
||||||
Normally this program generates the key and asks for a file in which
|
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
|
to store the private key.
|
||||||
same name but
|
The public key is stored in a file with the same name but
|
||||||
.Dq .pub
|
.Dq .pub
|
||||||
appended. The program also asks for a
|
appended.
|
||||||
passphrase. The passphrase may be empty to indicate no passphrase
|
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
|
(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
|
not simple sentences or otherwise easily guessable (English
|
||||||
prose has only 1-2 bits of entropy per word, and provides very bad
|
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
|
.Fl p
|
||||||
option.
|
option.
|
||||||
.Pp
|
.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
|
lost or forgotten, you will have to generate a new key and copy the
|
||||||
corresponding public key to other machines.
|
corresponding public key to other machines.
|
||||||
.Pp
|
.Pp
|
||||||
There is also a comment field in the key file that is only for
|
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
|
convenience to the user to help identify the key.
|
||||||
tell what the key is for, or whatever is useful. The comment is
|
The comment can tell what the key is for, or whatever is useful.
|
||||||
initialized to
|
The comment is initialized to
|
||||||
.Dq user@host
|
.Dq user@host
|
||||||
when the key is created, but can be changed using the
|
when the key is created, but can be changed using the
|
||||||
.Fl c
|
.Fl c
|
||||||
@ -77,10 +81,11 @@ option.
|
|||||||
The options are as follows:
|
The options are as follows:
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Fl b Ar bits
|
.It Fl b Ar bits
|
||||||
Specifies the number of bits in the key to create. Minimum is 512
|
Specifies the number of bits in the key to create.
|
||||||
bits. Generally 1024 bits is considered sufficient, and key sizes
|
Minimum is 512 bits.
|
||||||
above that no longer improve security but make things slower. The
|
Generally 1024 bits is considered sufficient, and key sizes
|
||||||
default is 1024 bits.
|
above that no longer improve security but make things slower.
|
||||||
|
The default is 1024 bits.
|
||||||
.It Fl c
|
.It Fl c
|
||||||
Requests changing the comment in the private and public key files.
|
Requests changing the comment in the private and public key files.
|
||||||
The program will prompt for the file containing the private keys, for
|
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.
|
Show fingerprint of specified private or public key file.
|
||||||
.It Fl p
|
.It Fl p
|
||||||
Requests changing the passphrase of a private key file instead of
|
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
|
containing the private key, for the old passphrase, and twice for the
|
||||||
new passphrase.
|
new passphrase.
|
||||||
.It Fl q
|
.It Fl q
|
||||||
@ -110,28 +116,30 @@ Provides the (old) passphrase.
|
|||||||
.Sh FILES
|
.Sh FILES
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Pa $HOME/.ssh/identity
|
.It Pa $HOME/.ssh/identity
|
||||||
Contains the RSA authentication identity of the user. This file
|
Contains the RSA authentication identity of the user.
|
||||||
should not be readable by anyone but the user. It is possible to
|
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
|
specify a passphrase when generating the key; that passphrase will be
|
||||||
used to encrypt the private part of this file using 3DES. This file
|
used to encrypt the private part of this file using 3DES.
|
||||||
is not automatically accessed by
|
This file is not automatically accessed by
|
||||||
.Nm
|
.Nm
|
||||||
but it is offered as the default file for the private key.
|
but it is offered as the default file for the private key.
|
||||||
.It Pa $HOME/.ssh/identity.pub
|
.It Pa $HOME/.ssh/identity.pub
|
||||||
Contains the public key for authentication. The contents of this file
|
Contains the public key for authentication.
|
||||||
should be added to
|
The contents of this file should be added to
|
||||||
.Pa $HOME/.ssh/authorized_keys
|
.Pa $HOME/.ssh/authorized_keys
|
||||||
on all machines
|
on all machines
|
||||||
where you wish to log in using RSA authentication. There is no
|
where you wish to log in using RSA authentication.
|
||||||
need to keep the contents of this file secret.
|
There is no need to keep the contents of this file secret.
|
||||||
.Sh AUTHOR
|
.Sh AUTHOR
|
||||||
Tatu Ylonen <ylo@cs.hut.fi>
|
Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
.Pp
|
.Pp
|
||||||
OpenSSH
|
OpenSSH
|
||||||
is a derivative of the original (free) ssh 1.2.12 release, but with bugs
|
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,
|
removed and newer features re-added.
|
||||||
newer versions bore successively more restrictive licenses. This version
|
Rapidly after the 1.2.12 release,
|
||||||
of OpenSSH
|
newer versions bore successively more restrictive licenses.
|
||||||
|
This version of OpenSSH
|
||||||
.Bl -bullet
|
.Bl -bullet
|
||||||
.It
|
.It
|
||||||
has all components of a restrictive nature (i.e., patents, see
|
has all components of a restrictive nature (i.e., patents, see
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "rsa.h"
|
||||||
#include "ssh.h"
|
#include "ssh.h"
|
||||||
@ -81,6 +81,7 @@ do_fingerprint(struct passwd *pw)
|
|||||||
RSA *public_key;
|
RSA *public_key;
|
||||||
char *comment = NULL, *cp, *ep, line[16*1024];
|
char *comment = NULL, *cp, *ep, line[16*1024];
|
||||||
int i, skip = 0, num = 1, invalid = 1;
|
int i, skip = 0, num = 1, invalid = 1;
|
||||||
|
unsigned int ignore;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (!have_identity)
|
if (!have_identity)
|
||||||
@ -138,7 +139,7 @@ do_fingerprint(struct passwd *pw)
|
|||||||
*cp++ = '\0';
|
*cp++ = '\0';
|
||||||
}
|
}
|
||||||
ep = cp;
|
ep = cp;
|
||||||
if (auth_rsa_read_key(&cp, &i, e, n)) {
|
if (auth_rsa_read_key(&cp, &ignore, e, n)) {
|
||||||
invalid = 0;
|
invalid = 0;
|
||||||
comment = *cp ? cp : comment;
|
comment = *cp ? cp : comment;
|
||||||
printf("%d %s %s\n", BN_num_bits(n),
|
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"
|
#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 "xmalloc.h"
|
||||||
#include "ssh.h"
|
#include "ssh.h"
|
||||||
@ -93,6 +93,7 @@ usage()
|
|||||||
fprintf(stderr, " -k Disable Kerberos ticket and AFS token forwarding.\n");
|
fprintf(stderr, " -k Disable Kerberos ticket and AFS token forwarding.\n");
|
||||||
#endif /* AFS */
|
#endif /* AFS */
|
||||||
fprintf(stderr, " -x Disable X11 connection forwarding.\n");
|
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, " -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, " -t Tty; allocate a tty even if command is given.\n");
|
||||||
fprintf(stderr, " -v Verbose; display verbose debugging messages.\n");
|
fprintf(stderr, " -v Verbose; display verbose debugging messages.\n");
|
||||||
@ -170,6 +171,7 @@ main(int ac, char **av)
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
struct passwd *pw, pwcopy;
|
struct passwd *pw, pwcopy;
|
||||||
int interactive = 0, dummy;
|
int interactive = 0, dummy;
|
||||||
|
int have_pty = 0;
|
||||||
uid_t original_effective_uid;
|
uid_t original_effective_uid;
|
||||||
int plen;
|
int plen;
|
||||||
|
|
||||||
@ -609,9 +611,6 @@ main(int ac, char **av)
|
|||||||
if (host_private_key_loaded)
|
if (host_private_key_loaded)
|
||||||
RSA_free(host_private_key); /* Destroys contents safely */
|
RSA_free(host_private_key); /* Destroys contents safely */
|
||||||
|
|
||||||
/* Close connection cleanly after attack. */
|
|
||||||
cipher_attack_detected = packet_disconnect;
|
|
||||||
|
|
||||||
/* Enable compression if requested. */
|
/* Enable compression if requested. */
|
||||||
if (options.compression) {
|
if (options.compression) {
|
||||||
debug("Requesting compression at level %d.", options.compression_level);
|
debug("Requesting compression at level %d.", options.compression_level);
|
||||||
@ -663,9 +662,10 @@ main(int ac, char **av)
|
|||||||
|
|
||||||
/* Read response from the server. */
|
/* Read response from the server. */
|
||||||
type = packet_read(&plen);
|
type = packet_read(&plen);
|
||||||
if (type == SSH_SMSG_SUCCESS)
|
if (type == SSH_SMSG_SUCCESS) {
|
||||||
interactive = 1;
|
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.");
|
log("Warning: Remote host failed or refused to allocate a pseudo tty.");
|
||||||
else
|
else
|
||||||
packet_disconnect("Protocol error waiting for pty request response.");
|
packet_disconnect("Protocol error waiting for pty request response.");
|
||||||
@ -793,7 +793,7 @@ main(int ac, char **av)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Enter the interactive session. */
|
/* 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. */
|
/* Close the connection to the remote host. */
|
||||||
packet_close();
|
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
|
#ifndef SSH_H
|
||||||
#define 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.
|
* its host key. Returns true if authentication succeeds.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
auth_rhosts_rsa(struct passwd * pw, const char *client_user,
|
auth_rhosts_rsa(struct passwd * pw, const char *client_user, RSA* client_host_key);
|
||||||
BIGNUM * client_host_key_e, BIGNUM * client_host_key_n);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tries to authenticate the user using password. Returns true if
|
* Tries to authenticate the user using password. Returns true if
|
||||||
@ -362,41 +361,12 @@ int get_remote_port(void);
|
|||||||
int get_local_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,
|
* Performs the RSA authentication challenge-response dialog with the client,
|
||||||
* and returns true (non-zero) if the client gave the correct answer to our
|
* and returns true (non-zero) if the client gave the correct answer to our
|
||||||
* challenge; returns zero if the client gives a wrong answer.
|
* 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
|
* 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
|
.include <bsd.own.mk> # for AFS
|
||||||
|
|
||||||
.if (${KERBEROS} == "yes")
|
.if (${KERBEROS} == "yes")
|
||||||
CFLAGS+= -DKRB4 -I/usr/include/kerberosIV
|
CFLAGS+= -DKRB4 -I${DESTDIR}/usr/include/kerberosIV
|
||||||
LDADD+= -lkrb
|
LDADD+= -lkrb
|
||||||
DPADD+= ${LIBKRB}
|
DPADD+= ${LIBKRB}
|
||||||
.if (${AFS} == "yes")
|
.if (${AFS} == "yes")
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 <ssl/bn.h>
|
||||||
#include "xmalloc.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 "uidswap.h"
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "readconf.h"
|
#include "readconf.h"
|
||||||
#include "fingerprint.h"
|
|
||||||
|
|
||||||
|
#include <ssl/rsa.h>
|
||||||
|
#include <ssl/dsa.h>
|
||||||
#include <ssl/md5.h>
|
#include <ssl/md5.h>
|
||||||
|
#include "key.h"
|
||||||
|
#include "hostfile.h"
|
||||||
|
|
||||||
/* Session id for the current session. */
|
/* Session id for the current session. */
|
||||||
unsigned char session_id[16];
|
unsigned char session_id[16];
|
||||||
@ -632,6 +635,7 @@ try_kerberos_authentication()
|
|||||||
char *realm;
|
char *realm;
|
||||||
CREDENTIALS cred;
|
CREDENTIALS cred;
|
||||||
int r, type, plen;
|
int r, type, plen;
|
||||||
|
socklen_t slen;
|
||||||
Key_schedule schedule;
|
Key_schedule schedule;
|
||||||
u_long checksum, cksum;
|
u_long checksum, cksum;
|
||||||
MSG_DAT msg_data;
|
MSG_DAT msg_data;
|
||||||
@ -674,16 +678,16 @@ try_kerberos_authentication()
|
|||||||
/* Zero the buffer. */
|
/* Zero the buffer. */
|
||||||
(void) memset(auth.dat, 0, MAX_KTXT_LEN);
|
(void) memset(auth.dat, 0, MAX_KTXT_LEN);
|
||||||
|
|
||||||
r = sizeof(local);
|
slen = sizeof(local);
|
||||||
memset(&local, 0, sizeof(local));
|
memset(&local, 0, sizeof(local));
|
||||||
if (getsockname(packet_get_connection_in(),
|
if (getsockname(packet_get_connection_in(),
|
||||||
(struct sockaddr *) & local, &r) < 0)
|
(struct sockaddr *) & local, &slen) < 0)
|
||||||
debug("getsockname failed: %s", strerror(errno));
|
debug("getsockname failed: %s", strerror(errno));
|
||||||
|
|
||||||
r = sizeof(foreign);
|
slen = sizeof(foreign);
|
||||||
memset(&foreign, 0, sizeof(foreign));
|
memset(&foreign, 0, sizeof(foreign));
|
||||||
if (getpeername(packet_get_connection_in(),
|
if (getpeername(packet_get_connection_in(),
|
||||||
(struct sockaddr *) & foreign, &r) < 0) {
|
(struct sockaddr *) & foreign, &slen) < 0) {
|
||||||
debug("getpeername failed: %s", strerror(errno));
|
debug("getpeername failed: %s", strerror(errno));
|
||||||
fatal_cleanup();
|
fatal_cleanup();
|
||||||
}
|
}
|
||||||
@ -745,7 +749,7 @@ send_kerberos_tgt()
|
|||||||
CREDENTIALS *creds;
|
CREDENTIALS *creds;
|
||||||
char pname[ANAME_SZ], pinst[INST_SZ], prealm[REALM_SZ];
|
char pname[ANAME_SZ], pinst[INST_SZ], prealm[REALM_SZ];
|
||||||
int r, type, plen;
|
int r, type, plen;
|
||||||
unsigned char buffer[8192];
|
char buffer[8192];
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
/* Don't do anything if we don't have any tickets. */
|
/* 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);
|
debug("Kerberos V4 ticket expired: %s", TKT_FILE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
creds_to_radix(creds, buffer);
|
creds_to_radix(creds, (unsigned char *)buffer);
|
||||||
xfree(creds);
|
xfree(creds);
|
||||||
|
|
||||||
packet_start(SSH_CMSG_HAVE_KERBEROS_TGT);
|
packet_start(SSH_CMSG_HAVE_KERBEROS_TGT);
|
||||||
packet_put_string((char *) buffer, strlen(buffer));
|
packet_put_string(buffer, strlen(buffer));
|
||||||
packet_send();
|
packet_send();
|
||||||
packet_write_wait();
|
packet_write_wait();
|
||||||
|
|
||||||
@ -792,7 +796,7 @@ send_afs_tokens(void)
|
|||||||
struct ClearToken ct;
|
struct ClearToken ct;
|
||||||
int i, type, len, plen;
|
int i, type, len, plen;
|
||||||
char buf[2048], *p, *server_cell;
|
char buf[2048], *p, *server_cell;
|
||||||
unsigned char buffer[8192];
|
char buffer[8192];
|
||||||
|
|
||||||
/* Move over ktc_GetToken, here's something leaner. */
|
/* Move over ktc_GetToken, here's something leaner. */
|
||||||
for (i = 0; i < 100; i++) { /* just in case */
|
for (i = 0; i < 100; i++) { /* just in case */
|
||||||
@ -834,10 +838,10 @@ send_afs_tokens(void)
|
|||||||
creds.pinst[0] = '\0';
|
creds.pinst[0] = '\0';
|
||||||
|
|
||||||
/* Encode token, ship it off. */
|
/* Encode token, ship it off. */
|
||||||
if (!creds_to_radix(&creds, buffer))
|
if (!creds_to_radix(&creds, (unsigned char*) buffer))
|
||||||
break;
|
break;
|
||||||
packet_start(SSH_CMSG_HAVE_AFS_TOKEN);
|
packet_start(SSH_CMSG_HAVE_AFS_TOKEN);
|
||||||
packet_put_string((char *) buffer, strlen(buffer));
|
packet_put_string(buffer, strlen(buffer));
|
||||||
packet_send();
|
packet_send();
|
||||||
packet_write_wait();
|
packet_write_wait();
|
||||||
|
|
||||||
@ -861,7 +865,9 @@ send_afs_tokens(void)
|
|||||||
int
|
int
|
||||||
try_skey_authentication()
|
try_skey_authentication()
|
||||||
{
|
{
|
||||||
int type, i, payload_len;
|
int type, i;
|
||||||
|
int payload_len;
|
||||||
|
unsigned int clen;
|
||||||
char *challenge, *response;
|
char *challenge, *response;
|
||||||
|
|
||||||
debug("Doing skey authentication.");
|
debug("Doing skey authentication.");
|
||||||
@ -881,7 +887,8 @@ try_skey_authentication()
|
|||||||
debug("No challenge for skey authentication.");
|
debug("No challenge for skey authentication.");
|
||||||
return 0;
|
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)
|
if (options.cipher == SSH_CIPHER_NONE)
|
||||||
log("WARNING: Encryption is disabled! "
|
log("WARNING: Encryption is disabled! "
|
||||||
"Reponse will be transmitted in clear text.");
|
"Reponse will be transmitted in clear text.");
|
||||||
@ -1063,9 +1070,9 @@ read_yes_or_no(const char *prompt, int defval)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
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 *ip = NULL;
|
||||||
char hostline[1000], *hostp;
|
char hostline[1000], *hostp;
|
||||||
HostStatus host_status;
|
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
|
* Store the host key from the known host file in here so that we can
|
||||||
* compare it with the key for the IP address.
|
* compare it with the key for the IP address.
|
||||||
*/
|
*/
|
||||||
file_key = RSA_new();
|
file_key = key_new(host_key->type);
|
||||||
file_key->n = BN_new();
|
|
||||||
file_key->e = BN_new();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if the host key is present in the user\'s list of known
|
* Check if the host key is present in the user\'s list of known
|
||||||
* hosts or in the systemwide list.
|
* hosts or in the systemwide list.
|
||||||
*/
|
*/
|
||||||
host_status = check_host_in_hostfile(options.user_hostfile, host,
|
host_status = check_host_in_hostfile(options.user_hostfile, host, host_key, file_key);
|
||||||
host_key->e, host_key->n,
|
|
||||||
file_key->e, file_key->n);
|
|
||||||
if (host_status == HOST_NEW)
|
if (host_status == HOST_NEW)
|
||||||
host_status = check_host_in_hostfile(options.system_hostfile, host,
|
host_status = check_host_in_hostfile(options.system_hostfile, host, host_key, file_key);
|
||||||
host_key->e, host_key->n,
|
|
||||||
file_key->e, file_key->n);
|
|
||||||
/*
|
/*
|
||||||
* Also perform check for the ip address, skip the check if we are
|
* Also perform check for the ip address, skip the check if we are
|
||||||
* localhost or the hostname was an ip address to begin with
|
* localhost or the hostname was an ip address to begin with
|
||||||
*/
|
*/
|
||||||
if (options.check_host_ip && !local && strcmp(host, ip)) {
|
if (options.check_host_ip && !local && strcmp(host, ip)) {
|
||||||
RSA *ip_key = RSA_new();
|
Key *ip_key = key_new(host_key->type);
|
||||||
ip_key->n = BN_new();
|
ip_status = check_host_in_hostfile(options.user_hostfile, ip, host_key, ip_key);
|
||||||
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);
|
|
||||||
|
|
||||||
if (ip_status == HOST_NEW)
|
if (ip_status == HOST_NEW)
|
||||||
ip_status = check_host_in_hostfile(options.system_hostfile, ip,
|
ip_status = check_host_in_hostfile(options.system_hostfile, ip, host_key, ip_key);
|
||||||
host_key->e, host_key->n,
|
|
||||||
ip_key->e, ip_key->n);
|
|
||||||
if (host_status == HOST_CHANGED &&
|
if (host_status == HOST_CHANGED &&
|
||||||
(ip_status != HOST_CHANGED ||
|
(ip_status != HOST_CHANGED || !key_equal(ip_key, file_key)))
|
||||||
(BN_cmp(ip_key->e, file_key->e) || BN_cmp(ip_key->n, file_key->n))))
|
|
||||||
host_ip_differ = 1;
|
host_ip_differ = 1;
|
||||||
|
|
||||||
RSA_free(ip_key);
|
key_free(ip_key);
|
||||||
} else
|
} else
|
||||||
ip_status = host_status;
|
ip_status = host_status;
|
||||||
|
|
||||||
RSA_free(file_key);
|
key_free(file_key);
|
||||||
|
|
||||||
switch (host_status) {
|
switch (host_status) {
|
||||||
case HOST_OK:
|
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);
|
debug("Host '%.200s' is known and matches the host key.", host);
|
||||||
if (options.check_host_ip) {
|
if (options.check_host_ip) {
|
||||||
if (ip_status == HOST_NEW) {
|
if (ip_status == HOST_NEW) {
|
||||||
if (!add_host_to_hostfile(options.user_hostfile, ip,
|
if (!add_host_to_hostfile(options.user_hostfile, ip, host_key))
|
||||||
host_key->e, host_key->n))
|
|
||||||
log("Failed to add the host key for IP address '%.30s' to the list of known hosts (%.30s).",
|
log("Failed to add the host key for IP address '%.30s' to the list of known hosts (%.30s).",
|
||||||
ip, options.user_hostfile);
|
ip, options.user_hostfile);
|
||||||
else
|
else
|
||||||
@ -1184,12 +1177,12 @@ check_host_key(char *host, struct sockaddr *hostaddr, RSA *host_key)
|
|||||||
} else if (options.strict_host_key_checking == 2) {
|
} else if (options.strict_host_key_checking == 2) {
|
||||||
/* The default */
|
/* The default */
|
||||||
char prompt[1024];
|
char prompt[1024];
|
||||||
char *fp = fingerprint(host_key->e, host_key->n);
|
char *fp = key_fingerprint(host_key);
|
||||||
snprintf(prompt, sizeof(prompt),
|
snprintf(prompt, sizeof(prompt),
|
||||||
"The authenticity of host '%.200s' can't be established.\n"
|
"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)? ",
|
"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))
|
if (!read_yes_or_no(prompt, -1))
|
||||||
fatal("Aborted by user!\n");
|
fatal("Aborted by user!\n");
|
||||||
}
|
}
|
||||||
@ -1200,8 +1193,7 @@ check_host_key(char *host, struct sockaddr *hostaddr, RSA *host_key)
|
|||||||
hostp = host;
|
hostp = host;
|
||||||
|
|
||||||
/* If not in strict mode, add the key automatically to the local known_hosts file. */
|
/* If not in strict mode, add the key automatically to the local known_hosts file. */
|
||||||
if (!add_host_to_hostfile(options.user_hostfile, hostp,
|
if (!add_host_to_hostfile(options.user_hostfile, hostp, host_key))
|
||||||
host_key->e, host_key->n))
|
|
||||||
log("Failed to add the host to the list of known hosts (%.500s).",
|
log("Failed to add the host to the list of known hosts (%.500s).",
|
||||||
options.user_hostfile);
|
options.user_hostfile);
|
||||||
else
|
else
|
||||||
@ -1269,6 +1261,14 @@ check_host_key(char *host, struct sockaddr *hostaddr, RSA *host_key)
|
|||||||
if (options.check_host_ip)
|
if (options.check_host_ip)
|
||||||
xfree(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
|
* 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,
|
8 + 4 + sum_len + 0 + 4 + 0 + 0 + 4 + 4 + 4,
|
||||||
SSH_SMSG_PUBLIC_KEY);
|
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;
|
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.");
|
fatal("Permission denied.");
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Starts a dialog with the server, and authenticates the current user on the
|
* Starts a dialog with the server, and authenticates the current user on the
|
||||||
* server. This does not need any extra privileges. The basic connection
|
* 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);
|
ssh_kex(host, hostaddr);
|
||||||
if (supported_authentications == 0)
|
if (supported_authentications == 0)
|
||||||
fatal("supported_authentications == 0.");
|
fatal("supported_authentications == 0.");
|
||||||
|
|
||||||
/* authenticate user */
|
/* authenticate user */
|
||||||
ssh_userauth(host_key_valid, own_host_key, original_real_uid, host);
|
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
|
.\" 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
|
.Dd September 25, 1999
|
||||||
.Dt SSHD 8
|
.Dt SSHD 8
|
||||||
@ -33,39 +33,48 @@
|
|||||||
.Xr ssh 1 .
|
.Xr ssh 1 .
|
||||||
Together these programs replace rlogin and rsh programs, and
|
Together these programs replace rlogin and rsh programs, and
|
||||||
provide secure encrypted communications between two untrusted hosts
|
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.
|
install and use as possible.
|
||||||
.Pp
|
.Pp
|
||||||
.Nm
|
.Nm
|
||||||
is the daemon that listens for connections from clients. It is
|
is the daemon that listens for connections from clients.
|
||||||
normally started at boot from
|
It is normally started at boot from
|
||||||
.Pa /etc/rc .
|
.Pa /etc/rc .
|
||||||
It forks a new
|
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,
|
key exchange, encryption, authentication, command execution,
|
||||||
and data exchange.
|
and data exchange.
|
||||||
.Pp
|
.Pp
|
||||||
.Nm
|
.Nm
|
||||||
works as follows. Each host has a host-specific RSA key
|
works as follows.
|
||||||
(normally 1024 bits) used to identify the host. Additionally, when
|
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).
|
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
|
This key is normally regenerated every hour if it has been used, and
|
||||||
is never stored on disk.
|
is never stored on disk.
|
||||||
.Pp
|
.Pp
|
||||||
Whenever a client connects the daemon, the daemon sends its host
|
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.
|
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
|
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
|
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
|
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.
|
to use from those offered by the server.
|
||||||
.Pp
|
.Pp
|
||||||
Next, the server and the client enter an authentication dialog. The
|
Next, the server and the client enter an authentication dialog.
|
||||||
client tries to authenticate itself using
|
The client tries to authenticate itself using
|
||||||
.Pa .rhosts
|
.Pa .rhosts
|
||||||
authentication,
|
authentication,
|
||||||
.Pa .rhosts
|
.Pa .rhosts
|
||||||
@ -75,7 +84,8 @@ based authentication.
|
|||||||
.Pp
|
.Pp
|
||||||
Rhosts authentication is normally disabled
|
Rhosts authentication is normally disabled
|
||||||
because it is fundamentally insecure, but can be enabled in the server
|
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 rshd 8 ,
|
||||||
.Xr rlogind 8 ,
|
.Xr rlogind 8 ,
|
||||||
.Xr rexecd 8 ,
|
.Xr rexecd 8 ,
|
||||||
@ -88,13 +98,15 @@ and
|
|||||||
into that machine).
|
into that machine).
|
||||||
.Pp
|
.Pp
|
||||||
If the client successfully authenticates itself, a dialog for
|
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,
|
things like allocating a pseudo-tty, forwarding X11 connections,
|
||||||
forwarding TCP/IP connections, or forwarding the authentication agent
|
forwarding TCP/IP connections, or forwarding the authentication agent
|
||||||
connection over the secure channel.
|
connection over the secure channel.
|
||||||
.Pp
|
.Pp
|
||||||
Finally, the client either requests a shell or execution of a command.
|
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
|
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.
|
command on the server side, and the user terminal in the client side.
|
||||||
.Pp
|
.Pp
|
||||||
@ -104,7 +116,8 @@ the client, and both sides exit.
|
|||||||
.Pp
|
.Pp
|
||||||
.Nm
|
.Nm
|
||||||
can be configured using command-line options or a configuration
|
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.
|
configuration file.
|
||||||
.Pp
|
.Pp
|
||||||
.Nm
|
.Nm
|
||||||
@ -117,20 +130,23 @@ The options are as follows:
|
|||||||
Specifies the number of bits in the server key (default 768).
|
Specifies the number of bits in the server key (default 768).
|
||||||
.Pp
|
.Pp
|
||||||
.It Fl d
|
.It Fl d
|
||||||
Debug mode. The server sends verbose debug output to the system
|
Debug mode.
|
||||||
log, and does not put itself in the background. The server also will
|
The server sends verbose debug output to the system
|
||||||
not fork and will only process one connection. This option is only
|
log, and does not put itself in the background.
|
||||||
intended for debugging for the server.
|
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
|
.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 .
|
.Pa /etc/sshd_config .
|
||||||
.Nm
|
.Nm
|
||||||
refuses to start if there is no configuration file.
|
refuses to start if there is no configuration file.
|
||||||
.It Fl g Ar login_grace_time
|
.It Fl g Ar login_grace_time
|
||||||
Gives the grace time for clients to authenticate themselves (default
|
Gives the grace time for clients to authenticate themselves (default
|
||||||
300 seconds). If the client fails to authenticate the user within
|
300 seconds).
|
||||||
this many seconds, the server disconnects and exits. A value of zero
|
If the client fails to authenticate the user within
|
||||||
indicates no limit.
|
this many seconds, the server disconnects and exits.
|
||||||
|
A value of zero indicates no limit.
|
||||||
.It Fl h Ar host_key_file
|
.It Fl h Ar host_key_file
|
||||||
Specifies the file from which the host key is read (default
|
Specifies the file from which the host key is read (default
|
||||||
.Pa /etc/ssh_host_key ) .
|
.Pa /etc/ssh_host_key ) .
|
||||||
@ -145,24 +161,28 @@ is being run from inetd.
|
|||||||
.Nm
|
.Nm
|
||||||
is normally not run
|
is normally not run
|
||||||
from inetd because it needs to generate the server key before it can
|
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
|
respond to the client, and this may take tens of seconds.
|
||||||
would have to wait too long if the key was regenerated every time.
|
Clients would have to wait too long if the key was regenerated every time.
|
||||||
However, with small key sizes (e.g. 512) using
|
However, with small key sizes (e.g., 512) using
|
||||||
.Nm
|
.Nm
|
||||||
from inetd may
|
from inetd may
|
||||||
be feasible.
|
be feasible.
|
||||||
.It Fl k Ar key_gen_time
|
.It Fl k Ar key_gen_time
|
||||||
Specifies how often the server key is regenerated (default 3600
|
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,
|
often is that the key is not stored anywhere, and after about an hour,
|
||||||
it becomes impossible to recover the key for decrypting intercepted
|
it becomes impossible to recover the key for decrypting intercepted
|
||||||
communications even if the machine is cracked into or physically
|
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
|
.It Fl p Ar port
|
||||||
Specifies the port on which the server listens for connections
|
Specifies the port on which the server listens for connections
|
||||||
(default 22).
|
(default 22).
|
||||||
.It Fl q
|
.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.
|
authentication, and termination of each connection is logged.
|
||||||
.It Fl Q
|
.It Fl Q
|
||||||
Do not print an error message if RSA support is missing.
|
Do not print an error message if RSA support is missing.
|
||||||
@ -188,39 +208,43 @@ reads configuration data from
|
|||||||
.Pa /etc/sshd_config
|
.Pa /etc/sshd_config
|
||||||
(or the file specified with
|
(or the file specified with
|
||||||
.Fl f
|
.Fl f
|
||||||
on the command line). The file
|
on the command line).
|
||||||
contains keyword-value pairs, one per line. Lines starting with
|
The file contains keyword-value pairs, one per line.
|
||||||
|
Lines starting with
|
||||||
.Ql #
|
.Ql #
|
||||||
and empty lines are interpreted as comments.
|
and empty lines are interpreted as comments.
|
||||||
.Pp
|
.Pp
|
||||||
The following keywords are possible.
|
The following keywords are possible.
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Cm AFSTokenPassing
|
.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 .
|
.Dq yes .
|
||||||
.It Cm AllowGroups
|
.It Cm AllowGroups
|
||||||
This keyword can be followed by a number of group names, separated
|
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.
|
group matches one of the patterns.
|
||||||
.Ql \&*
|
.Ql \&*
|
||||||
and
|
and
|
||||||
.Ql ?
|
.Ql ?
|
||||||
can be used as
|
can be used as
|
||||||
wildcards in the patterns. Only group names are valid, a numerical group
|
wildcards in the patterns.
|
||||||
id isn't recognized. By default login is allowed regardless of
|
Only group names are valid, a numerical group ID isn't recognized.
|
||||||
the primary group.
|
By default login is allowed regardless of the primary group.
|
||||||
.Pp
|
.Pp
|
||||||
.It Cm AllowUsers
|
.It Cm AllowUsers
|
||||||
This keyword can be followed by a number of user names, separated
|
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.
|
match one of the patterns.
|
||||||
.Ql \&*
|
.Ql \&*
|
||||||
and
|
and
|
||||||
.Ql ?
|
.Ql ?
|
||||||
can be used as
|
can be used as
|
||||||
wildcards in the patterns. Only user names are valid, a numerical user
|
wildcards in the patterns.
|
||||||
id isn't recognized. By default login is allowed regardless of
|
Only user names are valid, a numerical user ID isn't recognized.
|
||||||
the user name.
|
By default login is allowed regardless of the user name.
|
||||||
.Pp
|
.Pp
|
||||||
.It Cm CheckMail
|
.It Cm CheckMail
|
||||||
Specifies whether
|
Specifies whether
|
||||||
@ -230,27 +254,27 @@ The default is
|
|||||||
.Dq no .
|
.Dq no .
|
||||||
.It Cm DenyGroups
|
.It Cm DenyGroups
|
||||||
This keyword can be followed by a number of group names, separated
|
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.
|
aren't allowed to log in.
|
||||||
.Ql \&*
|
.Ql \&*
|
||||||
and
|
and
|
||||||
.Ql ?
|
.Ql ?
|
||||||
can be used as
|
can be used as
|
||||||
wildcards in the patterns. Only group names are valid, a numerical group
|
wildcards in the patterns.
|
||||||
id isn't recognized. By default login is allowed regardless of
|
Only group names are valid, a numerical group ID isn't recognized.
|
||||||
the primary group.
|
By default login is allowed regardless of the primary group.
|
||||||
.Pp
|
.Pp
|
||||||
.It Cm DenyUsers
|
.It Cm DenyUsers
|
||||||
This keyword can be followed by a number of user names, separated
|
This keyword can be followed by a number of user names, separated
|
||||||
by spaces. Login is disallowed for user names that match
|
by spaces.
|
||||||
one of the patterns.
|
Login is disallowed for user names that match one of the patterns.
|
||||||
.Ql \&*
|
.Ql \&*
|
||||||
and
|
and
|
||||||
.Ql ?
|
.Ql ?
|
||||||
can be used as
|
can be used as wildcards in the patterns.
|
||||||
wildcards in the patterns. Only user names are valid, a numerical user
|
Only user names are valid, a numerical user ID isn't recognized.
|
||||||
id isn't recognized. By default login is allowed regardless of
|
By default login is allowed regardless of the user name.
|
||||||
the user name.
|
|
||||||
.It Cm HostKey
|
.It Cm HostKey
|
||||||
Specifies the file containing the private host key (default
|
Specifies the file containing the private host key (default
|
||||||
.Pa /etc/ssh_host_key ) .
|
.Pa /etc/ssh_host_key ) .
|
||||||
@ -258,13 +282,17 @@ Note that
|
|||||||
.Nm
|
.Nm
|
||||||
does not start if this file is group/world-accessible.
|
does not start if this file is group/world-accessible.
|
||||||
.It Cm IgnoreRhosts
|
.It Cm IgnoreRhosts
|
||||||
Specifies that rhosts and shosts files will not be used in
|
Specifies that
|
||||||
authentication.
|
.Pa .rhosts
|
||||||
|
and
|
||||||
|
.Pa .shosts
|
||||||
|
files will not be used in authentication.
|
||||||
.Pa /etc/hosts.equiv
|
.Pa /etc/hosts.equiv
|
||||||
and
|
and
|
||||||
.Pa /etc/shosts.equiv
|
.Pa /etc/shosts.equiv
|
||||||
are still used. The default is
|
are still used.
|
||||||
.Dq no .
|
The default is
|
||||||
|
.Dq yes .
|
||||||
.It Cm IgnoreUserKnownHosts
|
.It Cm IgnoreUserKnownHosts
|
||||||
Specifies whether
|
Specifies whether
|
||||||
.Nm
|
.Nm
|
||||||
@ -276,10 +304,13 @@ The default is
|
|||||||
.Dq no .
|
.Dq no .
|
||||||
.It Cm KeepAlive
|
.It Cm KeepAlive
|
||||||
Specifies whether the system should send keepalive messages to the
|
Specifies whether the system should send keepalive messages to the
|
||||||
other side. If they are sent, death of the connection or crash of one
|
other side.
|
||||||
of the machines will be properly noticed. However, this means that
|
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
|
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
|
sessions may hang indefinitely on the server, leaving
|
||||||
.Dq ghost
|
.Dq ghost
|
||||||
users and consuming server resources.
|
users and consuming server resources.
|
||||||
@ -287,25 +318,27 @@ users and consuming server resources.
|
|||||||
The default is
|
The default is
|
||||||
.Dq yes
|
.Dq yes
|
||||||
(to send keepalives), and the server will notice
|
(to send keepalives), and the server will notice
|
||||||
if the network goes down or the client host reboots. This avoids
|
if the network goes down or the client host reboots.
|
||||||
infinitely hanging sessions.
|
This avoids infinitely hanging sessions.
|
||||||
.Pp
|
.Pp
|
||||||
To disable keepalives, the value should be set to
|
To disable keepalives, the value should be set to
|
||||||
.Dq no
|
.Dq no
|
||||||
in both the server and the client configuration files.
|
in both the server and the client configuration files.
|
||||||
.It Cm KerberosAuthentication
|
.It Cm KerberosAuthentication
|
||||||
Specifies whether Kerberos authentication is allowed. This can
|
Specifies whether Kerberos authentication is allowed.
|
||||||
be in the form of a Kerberos ticket, or if
|
This can be in the form of a Kerberos ticket, or if
|
||||||
.Cm PasswordAuthentication
|
.Cm PasswordAuthentication
|
||||||
is yes, the password provided by the user will be validated through
|
is yes, the password provided by the user will be validated through
|
||||||
the Kerberos KDC. Default is
|
the Kerberos KDC.
|
||||||
|
Default is
|
||||||
.Dq yes .
|
.Dq yes .
|
||||||
.It Cm KerberosOrLocalPasswd
|
.It Cm KerberosOrLocalPasswd
|
||||||
If set then if password authentication through Kerberos fails then
|
If set then if password authentication through Kerberos fails then
|
||||||
the password will be validated via any additional local mechanism
|
the password will be validated via any additional local mechanism
|
||||||
such as
|
such as
|
||||||
.Pa /etc/passwd
|
.Pa /etc/passwd
|
||||||
or SecurID. Default is
|
or SecurID.
|
||||||
|
Default is
|
||||||
.Dq yes .
|
.Dq yes .
|
||||||
.It Cm KerberosTgtPassing
|
.It Cm KerberosTgtPassing
|
||||||
Specifies whether a Kerberos TGT may be forwarded to the server.
|
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.
|
as this only works when the Kerberos KDC is actually an AFS kaserver.
|
||||||
.It Cm KerberosTicketCleanup
|
.It Cm KerberosTicketCleanup
|
||||||
Specifies whether to automatically destroy the user's ticket cache
|
Specifies whether to automatically destroy the user's ticket cache
|
||||||
file on logout. Default is
|
file on logout.
|
||||||
|
Default is
|
||||||
.Dq yes .
|
.Dq yes .
|
||||||
.It Cm KeyRegenerationInterval
|
.It Cm KeyRegenerationInterval
|
||||||
The server key is automatically regenerated after this many seconds
|
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
|
decrypting captured sessions by later breaking into the machine and
|
||||||
stealing the keys. The key is never stored anywhere. If the value is
|
stealing the keys.
|
||||||
0, the key is never regenerated. The default is 3600
|
The key is never stored anywhere.
|
||||||
(seconds).
|
If the value is 0, the key is never regenerated.
|
||||||
|
The default is 3600 (seconds).
|
||||||
.It Cm ListenAddress
|
.It Cm ListenAddress
|
||||||
Specifies what local address
|
Specifies what local address
|
||||||
.Nm
|
.Nm
|
||||||
@ -334,7 +370,8 @@ Additionally, the
|
|||||||
options must precede this option.
|
options must precede this option.
|
||||||
.It Cm LoginGraceTime
|
.It Cm LoginGraceTime
|
||||||
The server disconnects after this time if the user has not
|
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).
|
The default is 600 (seconds).
|
||||||
.It Cm LogLevel
|
.It Cm LogLevel
|
||||||
Gives the verbosity level that is used when logging messages from
|
Gives the verbosity level that is used when logging messages from
|
||||||
@ -350,9 +387,9 @@ The default is
|
|||||||
.Dq yes .
|
.Dq yes .
|
||||||
.It Cm PermitEmptyPasswords
|
.It Cm PermitEmptyPasswords
|
||||||
When password authentication is allowed, it specifies whether the
|
When password authentication is allowed, it specifies whether the
|
||||||
server allows login to accounts with empty password strings. The default
|
server allows login to accounts with empty password strings.
|
||||||
is
|
The default is
|
||||||
.Dq yes .
|
.Dq no .
|
||||||
.It Cm PermitRootLogin
|
.It Cm PermitRootLogin
|
||||||
Specifies whether the root can log in using
|
Specifies whether the root can log in using
|
||||||
.Xr ssh 1 .
|
.Xr ssh 1 .
|
||||||
@ -376,24 +413,27 @@ normally not allowed).
|
|||||||
.It Cm Port
|
.It Cm Port
|
||||||
Specifies the port number that
|
Specifies the port number that
|
||||||
.Nm
|
.Nm
|
||||||
listens on. The default is 22.
|
listens on.
|
||||||
|
The default is 22.
|
||||||
Multiple options of this type are permitted.
|
Multiple options of this type are permitted.
|
||||||
.It Cm PrintMotd
|
.It Cm PrintMotd
|
||||||
Specifies whether
|
Specifies whether
|
||||||
.Nm
|
.Nm
|
||||||
should print
|
should print
|
||||||
.Pa /etc/motd
|
.Pa /etc/motd
|
||||||
when a user logs in interactively. (On some systems it is also
|
when a user logs in interactively.
|
||||||
printed by the shell,
|
(On some systems it is also printed by the shell,
|
||||||
.Pa /etc/profile ,
|
.Pa /etc/profile ,
|
||||||
or equivalent.) The default is
|
or equivalent.)
|
||||||
|
The default is
|
||||||
.Dq yes .
|
.Dq yes .
|
||||||
.It Cm RandomSeed
|
.It Cm RandomSeed
|
||||||
Obsolete. Random number generation uses other techniques.
|
Obsolete.
|
||||||
|
Random number generation uses other techniques.
|
||||||
.It Cm RhostsAuthentication
|
.It Cm RhostsAuthentication
|
||||||
Specifies whether authentication using rhosts or /etc/hosts.equiv
|
Specifies whether authentication using rhosts or /etc/hosts.equiv
|
||||||
files is sufficient. Normally, this method should not be permitted
|
files is sufficient.
|
||||||
because it is insecure.
|
Normally, this method should not be permitted because it is insecure.
|
||||||
.Cm RhostsRSAAuthentication
|
.Cm RhostsRSAAuthentication
|
||||||
should be used
|
should be used
|
||||||
instead, because it performs RSA-based host authentication in addition
|
instead, because it performs RSA-based host authentication in addition
|
||||||
@ -402,18 +442,21 @@ The default is
|
|||||||
.Dq no .
|
.Dq no .
|
||||||
.It Cm RhostsRSAAuthentication
|
.It Cm RhostsRSAAuthentication
|
||||||
Specifies whether rhosts or /etc/hosts.equiv authentication together
|
Specifies whether rhosts or /etc/hosts.equiv authentication together
|
||||||
with successful RSA host authentication is allowed. The default is
|
with successful RSA host authentication is allowed.
|
||||||
.Dq yes .
|
The default is
|
||||||
|
.Dq no .
|
||||||
.It Cm RSAAuthentication
|
.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 .
|
.Dq yes .
|
||||||
.It Cm ServerKeyBits
|
.It Cm ServerKeyBits
|
||||||
Defines the number of bits in the server key. The minimum value is
|
Defines the number of bits in the server key.
|
||||||
512, and the default is 768.
|
The minimum value is 512, and the default is 768.
|
||||||
.It Cm SkeyAuthentication
|
.It Cm SkeyAuthentication
|
||||||
Specifies whether
|
Specifies whether
|
||||||
.Xr skey 1
|
.Xr skey 1
|
||||||
authentication is allowed. The default is
|
authentication is allowed.
|
||||||
|
The default is
|
||||||
.Dq yes .
|
.Dq yes .
|
||||||
Note that s/key authentication is enabled only if
|
Note that s/key authentication is enabled only if
|
||||||
.Cm PasswordAuthentication
|
.Cm PasswordAuthentication
|
||||||
@ -422,29 +465,35 @@ is allowed, too.
|
|||||||
Specifies whether
|
Specifies whether
|
||||||
.Nm
|
.Nm
|
||||||
should check file modes and ownership of the
|
should check file modes and ownership of the
|
||||||
user's files and home directory before accepting login. This
|
user's files and home directory before accepting login.
|
||||||
is normally desirable because novices sometimes accidentally leave their
|
This is normally desirable because novices sometimes accidentally leave their
|
||||||
directory or files world-writable. The default is
|
directory or files world-writable.
|
||||||
|
The default is
|
||||||
.Dq yes .
|
.Dq yes .
|
||||||
.It Cm SyslogFacility
|
.It Cm SyslogFacility
|
||||||
Gives the facility code that is used when logging messages from
|
Gives the facility code that is used when logging messages from
|
||||||
.Nm sshd .
|
.Nm sshd .
|
||||||
The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2,
|
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
|
.It Cm UseLogin
|
||||||
Specifies whether
|
Specifies whether
|
||||||
.Xr login 1
|
.Xr login 1
|
||||||
is used. The default is
|
is used.
|
||||||
|
The default is
|
||||||
.Dq no .
|
.Dq no .
|
||||||
.It Cm X11DisplayOffset
|
.It Cm X11DisplayOffset
|
||||||
Specifies the first display number available for
|
Specifies the first display number available for
|
||||||
.Nm sshd Ns 's
|
.Nm sshd Ns 's
|
||||||
X11 forwarding. This prevents
|
X11 forwarding.
|
||||||
|
This prevents
|
||||||
.Nm
|
.Nm
|
||||||
from interfering with real X11 servers.
|
from interfering with real X11 servers.
|
||||||
|
The default is 10.
|
||||||
.It Cm X11Forwarding
|
.It Cm X11Forwarding
|
||||||
Specifies whether X11 forwarding is permitted. The default is
|
Specifies whether X11 forwarding is permitted.
|
||||||
.Dq yes .
|
The default is
|
||||||
|
.Dq no .
|
||||||
Note that disabling X11 forwarding does not improve security in any
|
Note that disabling X11 forwarding does not improve security in any
|
||||||
way, as users can always install their own forwarders.
|
way, as users can always install their own forwarders.
|
||||||
.El
|
.El
|
||||||
@ -485,7 +534,8 @@ If
|
|||||||
exists, runs it; else if
|
exists, runs it; else if
|
||||||
.Pa /etc/sshrc
|
.Pa /etc/sshrc
|
||||||
exists, runs
|
exists, runs
|
||||||
it; otherwise runs xauth. The
|
it; otherwise runs xauth.
|
||||||
|
The
|
||||||
.Dq rc
|
.Dq rc
|
||||||
files are given the X11
|
files are given the X11
|
||||||
authentication protocol and cookie in standard input.
|
authentication protocol and cookie in standard input.
|
||||||
@ -496,12 +546,15 @@ Runs user's shell or command.
|
|||||||
The
|
The
|
||||||
.Pa $HOME/.ssh/authorized_keys
|
.Pa $HOME/.ssh/authorized_keys
|
||||||
file lists the RSA keys that are
|
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
|
key (empty lines and lines starting with a
|
||||||
.Ql #
|
.Ql #
|
||||||
are ignored as
|
are ignored as
|
||||||
comments). Each line consists of the following fields, separated by
|
comments).
|
||||||
spaces: options, bits, exponent, modulus, comment. The options field
|
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
|
is optional; its presence is determined by whether the line starts
|
||||||
with a number or not (the option field never starts with a number).
|
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
|
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).
|
user to identify the key).
|
||||||
.Pp
|
.Pp
|
||||||
Note that lines in this file are usually several hundred bytes long
|
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
|
(because of the size of the RSA key modulus).
|
||||||
them in; instead, copy the
|
You don't want to type them in; instead, copy the
|
||||||
.Pa identity.pub
|
.Pa identity.pub
|
||||||
file and edit it.
|
file and edit it.
|
||||||
.Pp
|
.Pp
|
||||||
The options (if present) consists of comma-separated option
|
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:
|
The following option specifications are supported:
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Cm from="pattern-list"
|
.It Cm from="pattern-list"
|
||||||
Specifies that in addition to RSA authentication, the canonical name
|
Specifies that in addition to RSA authentication, the canonical name
|
||||||
of the remote host must be present in the comma-separated list of
|
of the remote host must be present in the comma-separated list of
|
||||||
patterns ('*' and '?' serve as wildcards). The list may also contain
|
patterns
|
||||||
patterns negated by prefixing them with '!'; if the canonical host
|
.Pf ( Ql *
|
||||||
name matches a negated pattern, the key is not accepted. The purpose
|
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
|
of this option is to optionally increase security: RSA authentication
|
||||||
by itself does not trust the network or name servers or anything (but
|
by itself does not trust the network or name servers or anything (but
|
||||||
the key); however, if somebody somehow steals the key, the key
|
the key); however, if somebody somehow steals the key, the key
|
||||||
permits an intruder to log in from anywhere in the world. This
|
permits an intruder to log in from anywhere in the world.
|
||||||
additional option makes using a stolen key more difficult (name
|
This additional option makes using a stolen key more difficult (name
|
||||||
servers and/or routers would have to be compromised in addition to
|
servers and/or routers would have to be compromised in addition to
|
||||||
just the key).
|
just the key).
|
||||||
.It Cm command="command"
|
.It Cm command="command"
|
||||||
Specifies that the command is executed whenever this key is used for
|
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;
|
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
|
otherwise it is run without a tty.
|
||||||
command by quoting it with a backslash. This option might be useful
|
A quote may be included in the command by quoting it with a backslash.
|
||||||
to restrict certain RSA keys to perform just a specific operation. An
|
This option might be useful
|
||||||
example might be a key that permits remote backups but nothing
|
to restrict certain RSA keys to perform just a specific operation.
|
||||||
else. Notice that the client may specify TCP/IP and/or X11
|
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.
|
forwardings unless they are explicitly prohibited.
|
||||||
.It Cm environment="NAME=value"
|
.It Cm environment="NAME=value"
|
||||||
Specifies that the string is to be added to the environment when
|
Specifies that the string is to be added to the environment when
|
||||||
logging in using this key. Environment variables set this way
|
logging in using this key.
|
||||||
override other default environment values. Multiple options of this
|
Environment variables set this way
|
||||||
type are permitted.
|
override other default environment values.
|
||||||
|
Multiple options of this type are permitted.
|
||||||
.It Cm no-port-forwarding
|
.It Cm no-port-forwarding
|
||||||
Forbids TCP/IP forwarding when this key is used for authentication.
|
Forbids TCP/IP forwarding when this key is used for authentication.
|
||||||
Any port forward requests by the client will return an error. This
|
Any port forward requests by the client will return an error.
|
||||||
might be used, e.g., in connection with the
|
This might be used, e.g., in connection with the
|
||||||
.Cm command
|
.Cm command
|
||||||
option.
|
option.
|
||||||
.It Cm no-X11-forwarding
|
.It Cm no-X11-forwarding
|
||||||
@ -572,19 +636,21 @@ The
|
|||||||
.Pa /etc/ssh_known_hosts
|
.Pa /etc/ssh_known_hosts
|
||||||
and
|
and
|
||||||
.Pa $HOME/.ssh/known_hosts
|
.Pa $HOME/.ssh/known_hosts
|
||||||
files contain host public keys for all known hosts. The global file should
|
files contain host public keys for all known hosts.
|
||||||
be prepared by the admistrator (optional), and the per-user file is
|
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
|
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
|
.Pp
|
||||||
Each line in these files contains the following fields: hostnames,
|
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
|
.Pp
|
||||||
Hostnames is a comma-separated list of patterns ('*' and '?' act as
|
Hostnames is a comma-separated list of patterns ('*' and '?' act as
|
||||||
wildcards); each pattern in turn is matched against the canonical host
|
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 client) or against the user-supplied
|
||||||
name (when authenticating a server). A pattern may also be preceded
|
name (when authenticating a server).
|
||||||
by
|
A pattern may also be preceded by
|
||||||
.Ql !
|
.Ql !
|
||||||
to indicate negation: if the host name matches a negated
|
to indicate negation: if the host name matches a negated
|
||||||
pattern, it is not accepted (by that line) even if it matched another
|
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.
|
and empty lines are ignored as comments.
|
||||||
.Pp
|
.Pp
|
||||||
When performing host authentication, authentication is accepted if any
|
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
|
recommended) to have several lines or different host keys for the same
|
||||||
names. This will inevitably happen when short forms of host names
|
names.
|
||||||
from different domains are put in the file. It is possible
|
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
|
that the files contain conflicting information; authentication is
|
||||||
accepted if valid information can be found from either file.
|
accepted if valid information can be found from either file.
|
||||||
.Pp
|
.Pp
|
||||||
@ -632,7 +701,9 @@ does not start if this file is group/world-accessible.
|
|||||||
.It Pa /etc/ssh_host_key.pub
|
.It Pa /etc/ssh_host_key.pub
|
||||||
Contains the public part of the host key.
|
Contains the public part of the host key.
|
||||||
This file should be world-readable but writable only by
|
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
|
really used for anything; it is only provided for the convenience of
|
||||||
the user so its contents can be copied to known hosts files.
|
the user so its contents can be copied to known hosts files.
|
||||||
These two files are created using
|
These two files are created using
|
||||||
@ -642,21 +713,22 @@ Contains the process ID of the
|
|||||||
.Nm
|
.Nm
|
||||||
listening for connections (if there are several daemons running
|
listening for connections (if there are several daemons running
|
||||||
concurrently for different ports, this contains the pid of the one
|
concurrently for different ports, this contains the pid of the one
|
||||||
started last). The contents of this file are not sensitive; it can be
|
started last).
|
||||||
world-readable.
|
The contents of this file are not sensitive; it can be world-readable.
|
||||||
.It Pa $HOME/.ssh/authorized_keys
|
.It Pa $HOME/.ssh/authorized_keys
|
||||||
Lists the RSA keys that can be used to log into the user's account.
|
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
|
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
|
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
|
volume).
|
||||||
format of this file is described above.
|
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"
|
.It Pa "/etc/ssh_known_hosts" and "$HOME/.ssh/known_hosts"
|
||||||
These files are consulted when using rhosts with RSA host
|
These files are consulted when using rhosts with RSA host
|
||||||
authentication to check the public key of the host. The key must be
|
authentication to check the public key of the host.
|
||||||
listed in one of these files to be accepted.
|
The key must be listed in one of these files to be accepted.
|
||||||
The client uses the same files
|
The client uses the same files
|
||||||
to verify that the remote host is the one we intended to
|
to verify that the remote host is the one we intended to connect.
|
||||||
connect. These files should be writable only by root/the owner.
|
These files should be writable only by root/the owner.
|
||||||
.Pa /etc/ssh_known_hosts
|
.Pa /etc/ssh_known_hosts
|
||||||
should be world-readable, and
|
should be world-readable, and
|
||||||
.Pa $HOME/.ssh/known_hosts
|
.Pa $HOME/.ssh/known_hosts
|
||||||
@ -664,9 +736,11 @@ can but need not be world-readable.
|
|||||||
.It Pa /etc/nologin
|
.It Pa /etc/nologin
|
||||||
If this file exists,
|
If this file exists,
|
||||||
.Nm
|
.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
|
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
|
.It Pa /etc/hosts.allow, /etc/hosts.deny
|
||||||
If compiled with
|
If compiled with
|
||||||
.Sy LIBWRAP
|
.Sy LIBWRAP
|
||||||
@ -674,13 +748,16 @@ support, tcp-wrappers access controls may be defined here as described in
|
|||||||
.Xr hosts_access 5 .
|
.Xr hosts_access 5 .
|
||||||
.It Pa $HOME/.rhosts
|
.It Pa $HOME/.rhosts
|
||||||
This file contains host-username pairs, separated by a space, one per
|
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
|
line.
|
||||||
without password. The same file is used by rlogind and rshd.
|
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
|
The file must
|
||||||
be writable only by the user; it is recommended that it not be
|
be writable only by the user; it is recommended that it not be
|
||||||
accessible by others.
|
accessible by others.
|
||||||
.Pp
|
.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
|
name may be of the form +@groupname to specify all hosts or all users
|
||||||
in the group.
|
in the group.
|
||||||
.It Pa $HOME/.shosts
|
.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
|
.Pa /etc/hosts.equiv
|
||||||
This file is used during
|
This file is used during
|
||||||
.Pa .rhosts
|
.Pa .rhosts
|
||||||
authentication. In the
|
authentication.
|
||||||
simplest form, this file contains host names, one per line. Users on
|
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
|
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
|
followed by a user name; such users are permitted to log in as
|
||||||
.Em any
|
.Em any
|
||||||
user on this machine (except root). Additionally, the syntax
|
user on this machine (except root).
|
||||||
|
Additionally, the syntax
|
||||||
.Dq +@group
|
.Dq +@group
|
||||||
can be used to specify netgroups. Negated entries start with
|
can be used to specify netgroups.
|
||||||
|
Negated entries start with
|
||||||
.Ql \&- .
|
.Ql \&- .
|
||||||
.Pp
|
.Pp
|
||||||
If the client host/user is successfully matched in this file, login is
|
If the client host/user is successfully matched in this file, login is
|
||||||
automatically permitted provided the client and server user names are the
|
automatically permitted provided the client and server user names are the
|
||||||
same. Additionally, successful RSA host authentication is normally
|
same.
|
||||||
required. This file must be writable only by root; it is recommended
|
Additionally, successful RSA host authentication is normally required.
|
||||||
|
This file must be writable only by root; it is recommended
|
||||||
that it be world-readable.
|
that it be world-readable.
|
||||||
.Pp
|
.Pp
|
||||||
.Sy "Warning: It is almost never a good idea to use user names in"
|
.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
|
Beware that it really means that the named user(s) can log in as
|
||||||
.Em anybody ,
|
.Em anybody ,
|
||||||
which includes bin, daemon, adm, and other accounts that own critical
|
which includes bin, daemon, adm, and other accounts that own critical
|
||||||
binaries and directories. Using a user name practically grants the
|
binaries and directories.
|
||||||
user root access. The only valid use for user names that I can think
|
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.
|
of is in negative entries.
|
||||||
.Pp
|
.Pp
|
||||||
Note that this warning also applies to rsh/rlogin.
|
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
|
However, this file may be useful in environments that want to run both
|
||||||
rsh/rlogin and ssh.
|
rsh/rlogin and ssh.
|
||||||
.It Pa $HOME/.ssh/environment
|
.It Pa $HOME/.ssh/environment
|
||||||
This file is read into the environment at login (if it exists). It
|
This file is read into the environment at login (if it exists).
|
||||||
can only contain empty lines, comment lines (that start with
|
It can only contain empty lines, comment lines (that start with
|
||||||
.Ql # ) ,
|
.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.
|
only by the user; it need not be readable by anyone else.
|
||||||
.It Pa $HOME/.ssh/rc
|
.It Pa $HOME/.ssh/rc
|
||||||
If this file exists, it is run with /bin/sh after reading the
|
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
|
environment files but before starting the user's shell or command.
|
||||||
X11 spoofing is in use, this will receive the "proto cookie" pair in
|
If X11 spoofing is in use, this will receive the "proto cookie" pair in
|
||||||
standard input (and
|
standard input (and
|
||||||
.Ev DISPLAY
|
.Ev DISPLAY
|
||||||
in environment). This must call
|
in environment).
|
||||||
|
This must call
|
||||||
.Xr xauth 1
|
.Xr xauth 1
|
||||||
in that case.
|
in that case.
|
||||||
.Pp
|
.Pp
|
||||||
@ -759,12 +844,13 @@ readable by anyone else.
|
|||||||
Like
|
Like
|
||||||
.Pa $HOME/.ssh/rc .
|
.Pa $HOME/.ssh/rc .
|
||||||
This can be used to specify
|
This can be used to specify
|
||||||
machine-specific login-time initializations globally. This file
|
machine-specific login-time initializations globally.
|
||||||
should be writable only by root, and should be world-readable.
|
This file should be writable only by root, and should be world-readable.
|
||||||
.Sh AUTHOR
|
.Sh AUTHOR
|
||||||
OpenSSH
|
OpenSSH
|
||||||
is a derivative of the original (free) ssh 1.2.12 release by Tatu Ylonen,
|
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
|
1.2.12 release, newer versions of the original ssh bore successively
|
||||||
more restrictive licenses, and thus demand for a free version was born.
|
more restrictive licenses, and thus demand for a free version was born.
|
||||||
This version of OpenSSH
|
This version of OpenSSH
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "xmalloc.h"
|
||||||
#include "rsa.h"
|
#include "rsa.h"
|
||||||
@ -512,9 +512,6 @@ main(int ac, char **av)
|
|||||||
unmounted if desired. */
|
unmounted if desired. */
|
||||||
chdir("/");
|
chdir("/");
|
||||||
|
|
||||||
/* Close connection cleanly after attack. */
|
|
||||||
cipher_attack_detected = packet_disconnect;
|
|
||||||
|
|
||||||
/* Start listening for a socket, unless started from inetd. */
|
/* Start listening for a socket, unless started from inetd. */
|
||||||
if (inetd_flag) {
|
if (inetd_flag) {
|
||||||
int s1, s2;
|
int s1, s2;
|
||||||
@ -1183,7 +1180,8 @@ void
|
|||||||
do_authentication()
|
do_authentication()
|
||||||
{
|
{
|
||||||
struct passwd *pw, pwcopy;
|
struct passwd *pw, pwcopy;
|
||||||
int plen, ulen;
|
int plen;
|
||||||
|
unsigned int ulen;
|
||||||
char *user;
|
char *user;
|
||||||
|
|
||||||
/* Get the name of the user that we wish to log in as. */
|
/* Get the name of the user that we wish to log in as. */
|
||||||
@ -1244,14 +1242,6 @@ do_authentication()
|
|||||||
do_authloop(pw);
|
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. */
|
/* The user has been authenticated and accepted. */
|
||||||
packet_start(SSH_SMSG_SUCCESS);
|
packet_start(SSH_SMSG_SUCCESS);
|
||||||
packet_send();
|
packet_send();
|
||||||
@ -1274,11 +1264,13 @@ do_authloop(struct passwd * pw)
|
|||||||
{
|
{
|
||||||
int attempt = 0;
|
int attempt = 0;
|
||||||
unsigned int bits;
|
unsigned int bits;
|
||||||
BIGNUM *client_host_key_e, *client_host_key_n;
|
RSA *client_host_key;
|
||||||
BIGNUM *n;
|
BIGNUM *n;
|
||||||
char *client_user, *password;
|
char *client_user, *password;
|
||||||
char user[1024];
|
char user[1024];
|
||||||
int plen, dlen, nlen, ulen, elen;
|
unsigned int dlen;
|
||||||
|
int plen, nlen, elen;
|
||||||
|
unsigned int ulen;
|
||||||
int type = 0;
|
int type = 0;
|
||||||
void (*authlog) (const char *fmt,...) = verbose;
|
void (*authlog) (const char *fmt,...) = verbose;
|
||||||
|
|
||||||
@ -1389,21 +1381,24 @@ do_authloop(struct passwd * pw)
|
|||||||
client_user = packet_get_string(&ulen);
|
client_user = packet_get_string(&ulen);
|
||||||
|
|
||||||
/* Get the client host key. */
|
/* Get the client host key. */
|
||||||
client_host_key_e = BN_new();
|
client_host_key = RSA_new();
|
||||||
client_host_key_n = BN_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();
|
bits = packet_get_int();
|
||||||
packet_get_bignum(client_host_key_e, &elen);
|
packet_get_bignum(client_host_key->e, &elen);
|
||||||
packet_get_bignum(client_host_key_n, &nlen);
|
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: "
|
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);
|
packet_integrity_check(plen, (4 + ulen) + 4 + elen + nlen, type);
|
||||||
|
|
||||||
authenticated = auth_rhosts_rsa(pw, client_user,
|
authenticated = auth_rhosts_rsa(pw, client_user, client_host_key);
|
||||||
client_host_key_e, client_host_key_n);
|
RSA_free(client_host_key);
|
||||||
BN_clear_free(client_host_key_e);
|
|
||||||
BN_clear_free(client_host_key_n);
|
|
||||||
|
|
||||||
snprintf(user, sizeof user, " ruser %s", client_user);
|
snprintf(user, sizeof user, " ruser %s", client_user);
|
||||||
xfree(client_user);
|
xfree(client_user);
|
||||||
@ -1489,6 +1484,21 @@ do_authloop(struct passwd * pw)
|
|||||||
break;
|
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 */
|
/* Raise logging level */
|
||||||
if (authenticated ||
|
if (authenticated ||
|
||||||
attempt == AUTH_FAIL_LOG ||
|
attempt == AUTH_FAIL_LOG ||
|
||||||
@ -1544,7 +1554,7 @@ do_fake_authloop(char *user)
|
|||||||
int plen;
|
int plen;
|
||||||
int type = packet_read(&plen);
|
int type = packet_read(&plen);
|
||||||
#ifdef SKEY
|
#ifdef SKEY
|
||||||
int dlen;
|
unsigned int dlen;
|
||||||
char *password, *skeyinfo;
|
char *password, *skeyinfo;
|
||||||
/* Try to send a fake s/key challenge. */
|
/* Try to send a fake s/key challenge. */
|
||||||
if (options.skey_authentication == 1 &&
|
if (options.skey_authentication == 1 &&
|
||||||
@ -1628,6 +1638,8 @@ do_authenticated(struct passwd * pw)
|
|||||||
int row, col, xpixel, ypixel, screen;
|
int row, col, xpixel, ypixel, screen;
|
||||||
char ttyname[64];
|
char ttyname[64];
|
||||||
char *command, *term = NULL, *display = NULL, *proto = NULL, *data = NULL;
|
char *command, *term = NULL, *display = NULL, *proto = NULL, *data = NULL;
|
||||||
|
int plen;
|
||||||
|
unsigned int dlen;
|
||||||
int n_bytes;
|
int n_bytes;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1651,7 +1663,6 @@ do_authenticated(struct passwd * pw)
|
|||||||
* or a command.
|
* or a command.
|
||||||
*/
|
*/
|
||||||
while (1) {
|
while (1) {
|
||||||
int plen, dlen;
|
|
||||||
|
|
||||||
/* Get a packet from the client. */
|
/* Get a packet from the client. */
|
||||||
type = packet_read(&plen);
|
type = packet_read(&plen);
|
||||||
@ -1730,7 +1741,7 @@ do_authenticated(struct passwd * pw)
|
|||||||
if (display)
|
if (display)
|
||||||
packet_disconnect("Protocol error: X11 display already set.");
|
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);
|
proto = packet_get_string(&proto_len);
|
||||||
data = packet_get_string(&data_len);
|
data = packet_get_string(&data_len);
|
||||||
packet_integrity_check(plen, 4 + proto_len + 4 + data_len + 4, type);
|
packet_integrity_check(plen, 4 + proto_len + 4 + data_len + 4, type);
|
||||||
@ -1755,8 +1766,9 @@ do_authenticated(struct passwd * pw)
|
|||||||
xauthfile = NULL;
|
xauthfile = NULL;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
restore_uid();
|
|
||||||
strlcat(xauthfile, "/cookies", MAXPATHLEN);
|
strlcat(xauthfile, "/cookies", MAXPATHLEN);
|
||||||
|
open(xauthfile, O_RDWR|O_CREAT|O_EXCL, 0600);
|
||||||
|
restore_uid();
|
||||||
fatal_add_cleanup(xauthfile_cleanup_proc, NULL);
|
fatal_add_cleanup(xauthfile_cleanup_proc, NULL);
|
||||||
break;
|
break;
|
||||||
#else /* XAUTH_PATH */
|
#else /* XAUTH_PATH */
|
||||||
@ -1811,7 +1823,7 @@ do_authenticated(struct passwd * pw)
|
|||||||
goto do_forced_command;
|
goto do_forced_command;
|
||||||
/* Get command from the packet. */
|
/* Get command from the packet. */
|
||||||
{
|
{
|
||||||
int dlen;
|
unsigned int dlen;
|
||||||
command = packet_get_string(&dlen);
|
command = packet_get_string(&dlen);
|
||||||
debug("Executing command '%.500s'", command);
|
debug("Executing command '%.500s'", command);
|
||||||
packet_integrity_check(plen, 4 + dlen, type);
|
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");
|
f = popen(XAUTH_PATH " -q -", "w");
|
||||||
if (f) {
|
if (f) {
|
||||||
fprintf(f, "add %s %s %s\n", display, auth_proto, auth_data);
|
fprintf(f, "add %s %s %s\n", display, auth_proto, auth_data);
|
||||||
fclose(f);
|
pclose(f);
|
||||||
} else
|
} else
|
||||||
fprintf(stderr, "Could not run %s -q -\n", XAUTH_PATH);
|
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
|
.include <bsd.own.mk> # for KERBEROS and AFS
|
||||||
|
|
||||||
.if (${KERBEROS} == "yes")
|
.if (${KERBEROS} == "yes")
|
||||||
CFLAGS+= -DKRB4 -I/usr/include/kerberosIV
|
|
||||||
SRCS+= auth-krb4.c
|
|
||||||
LDADD+= -lkrb
|
|
||||||
DPADD+= ${LIBKRB}
|
|
||||||
.if (${AFS} == "yes")
|
.if (${AFS} == "yes")
|
||||||
CFLAGS+= -DAFS
|
CFLAGS+= -DAFS
|
||||||
LDADD+= -lkafs
|
LDADD+= -lkafs
|
||||||
DPADD+= ${LIBKRBAFS}
|
DPADD+= ${LIBKRBAFS}
|
||||||
.endif # AFS
|
.endif # AFS
|
||||||
|
CFLAGS+= -DKRB4 -I${DESTDIR}/usr/include/kerberosIV
|
||||||
|
SRCS+= auth-krb4.c
|
||||||
|
LDADD+= -lkrb
|
||||||
|
DPADD+= ${LIBKRB}
|
||||||
.endif # KERBEROS
|
.endif # KERBEROS
|
||||||
|
|
||||||
.if (${SKEY} == "yes")
|
.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