mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-27 07:44:29 +02:00
- OpenBSD CVS update
- [auth-krb4.c] -Wall - [auth-rh-rsa.c auth-rsa.c hostfile.c hostfile.h key.c key.h match.c] [match.h ssh.c ssh.h sshconnect.c sshd.c] initial support for DSA keys. ok deraadt@, niels@ - [cipher.c cipher.h] remove unused cipher_attack_detected code - [scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh.1 sshd.8] Fix some formatting problems I missed before. - [ssh.1 sshd.8] fix spelling errors, From: FreeBSD - [ssh.c] switch to raw mode only if he _get_ a pty (not if we _want_ a pty).
This commit is contained in:
parent
2c9279fa66
commit
450a7a1ff4
14
ChangeLog
14
ChangeLog
@ -2,6 +2,20 @@
|
|||||||
- Better tests for OpenSSL w/ RSAref
|
- Better tests for OpenSSL w/ RSAref
|
||||||
- Added replacement setenv() function from OpenBSD libc. Suggested by
|
- Added replacement setenv() function from OpenBSD libc. Suggested by
|
||||||
Ben Lindstrom <mouring@pconline.com>
|
Ben Lindstrom <mouring@pconline.com>
|
||||||
|
- OpenBSD CVS update
|
||||||
|
- [auth-krb4.c]
|
||||||
|
-Wall
|
||||||
|
- [auth-rh-rsa.c auth-rsa.c hostfile.c hostfile.h key.c key.h match.c]
|
||||||
|
[match.h ssh.c ssh.h sshconnect.c sshd.c]
|
||||||
|
initial support for DSA keys. ok deraadt@, niels@
|
||||||
|
- [cipher.c cipher.h]
|
||||||
|
remove unused cipher_attack_detected code
|
||||||
|
- [scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh.1 sshd.8]
|
||||||
|
Fix some formatting problems I missed before.
|
||||||
|
- [ssh.1 sshd.8]
|
||||||
|
fix spelling errors, From: FreeBSD
|
||||||
|
- [ssh.c]
|
||||||
|
switch to raw mode only if he _get_ a pty (not if we _want_ a pty).
|
||||||
|
|
||||||
20000324
|
20000324
|
||||||
- Released 1.2.3
|
- Released 1.2.3
|
||||||
|
@ -31,7 +31,7 @@ LDFLAGS=-L. @LDFLAGS@
|
|||||||
|
|
||||||
TARGETS=ssh sshd ssh-add ssh-keygen ssh-agent scp $(EXTRA_TARGETS)
|
TARGETS=ssh sshd ssh-add ssh-keygen ssh-agent scp $(EXTRA_TARGETS)
|
||||||
|
|
||||||
LIBOBJS= atomicio.o authfd.o authfile.o bsd-bindresvport.o bsd-daemon.o bsd-misc.o bsd-mktemp.o bsd-rresvport.o bsd-setenv.o bsd-snprintf.o bsd-strlcat.o bsd-strlcpy.o bufaux.o buffer.o canohost.o channels.o cipher.o compat.o compress.o crc32.o deattack.o fake-getaddrinfo.o fake-getnameinfo.o fingerprint.o hostfile.o log.o match.o mpaux.o nchan.o packet.o radix.o random.o readpass.o rsa.o tildexpand.o ttymodes.o uidswap.o xmalloc.o
|
LIBOBJS= atomicio.o authfd.o authfile.o bsd-bindresvport.o bsd-daemon.o bsd-misc.o bsd-mktemp.o bsd-rresvport.o bsd-setenv.o bsd-snprintf.o bsd-strlcat.o bsd-strlcpy.o bufaux.o buffer.o canohost.o channels.o cipher.o compat.o compress.o crc32.o deattack.o fake-getaddrinfo.o fake-getnameinfo.o fingerprint.o hostfile.o key.o log.o match.o mpaux.o nchan.o packet.o radix.o random.o readpass.o rsa.o tildexpand.o ttymodes.o uidswap.o xmalloc.o
|
||||||
|
|
||||||
SSHOBJS= ssh.o sshconnect.o log-client.o readconf.o clientloop.o
|
SSHOBJS= ssh.o sshconnect.o log-client.o readconf.o clientloop.o
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -15,7 +15,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$Id: auth-rh-rsa.c,v 1.7 1999/11/25 00:54:57 damien Exp $");
|
RCSID("$Id: auth-rh-rsa.c,v 1.8 2000/03/26 03:04:52 damien Exp $");
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENSSL
|
||||||
|
#include <openssl/bn.h>
|
||||||
|
#include <openssl/rsa.h>
|
||||||
|
#include <openssl/dsa.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SSL
|
||||||
|
#include <ssl/bn.h>
|
||||||
|
#include <ssl/rsa.h>
|
||||||
|
#include <ssl/dsa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
#include "ssh.h"
|
#include "ssh.h"
|
||||||
@ -23,37 +34,44 @@ RCSID("$Id: auth-rh-rsa.c,v 1.7 1999/11/25 00:54:57 damien Exp $");
|
|||||||
#include "uidswap.h"
|
#include "uidswap.h"
|
||||||
#include "servconf.h"
|
#include "servconf.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 +91,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 +107,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;
|
||||||
|
37
auth-rsa.c
37
auth-rsa.c
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$Id: auth-rsa.c,v 1.13 2000/03/09 10:27:50 damien Exp $");
|
RCSID("$Id: auth-rsa.c,v 1.14 2000/03/26 03:04:52 damien Exp $");
|
||||||
|
|
||||||
#include "rsa.h"
|
#include "rsa.h"
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
@ -24,6 +24,7 @@ RCSID("$Id: auth-rsa.c,v 1.13 2000/03/09 10:27:50 damien Exp $");
|
|||||||
#include "ssh.h"
|
#include "ssh.h"
|
||||||
#include "mpaux.h"
|
#include "mpaux.h"
|
||||||
#include "uidswap.h"
|
#include "uidswap.h"
|
||||||
|
#include "match.h"
|
||||||
#include "servconf.h"
|
#include "servconf.h"
|
||||||
|
|
||||||
#ifdef HAVE_OPENSSL
|
#ifdef HAVE_OPENSSL
|
||||||
@ -66,10 +67,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;
|
||||||
@ -82,19 +82,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);
|
||||||
@ -146,7 +138,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);
|
||||||
@ -208,8 +200,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
|
||||||
@ -247,7 +240,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",
|
||||||
@ -257,19 +250,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.");
|
||||||
@ -472,8 +466,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.");
|
||||||
|
16
cipher.c
16
cipher.c
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$Id: cipher.c,v 1.13 2000/03/09 10:27:50 damien Exp $");
|
RCSID("$Id: cipher.c,v 1.14 2000/03/26 03:04:52 damien Exp $");
|
||||||
|
|
||||||
#include "ssh.h"
|
#include "ssh.h"
|
||||||
#include "cipher.h"
|
#include "cipher.h"
|
||||||
@ -110,18 +110,6 @@ swap_bytes(const unsigned char *src, unsigned char *dst_, int n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void (*cipher_attack_detected) (const char *fmt,...) = fatal;
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
detect_cbc_attack(const unsigned char *src,
|
|
||||||
unsigned int len)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
|
|
||||||
log("CRC-32 CBC insertion attack detected");
|
|
||||||
cipher_attack_detected("CRC-32 CBC insertion attack detected");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Names of all encryption algorithms.
|
* Names of all encryption algorithms.
|
||||||
* These must match the numbers defined in cipher.h.
|
* These must match the numbers defined in cipher.h.
|
||||||
@ -304,7 +292,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,
|
||||||
@ -312,7 +299,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,
|
||||||
|
8
cipher.h
8
cipher.h
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* RCSID("$Id: cipher.h,v 1.5 1999/11/25 00:54:58 damien Exp $"); */
|
/* RCSID("$Id: cipher.h,v 1.6 2000/03/26 03:04:52 damien Exp $"); */
|
||||||
|
|
||||||
#ifndef CIPHER_H
|
#ifndef CIPHER_H
|
||||||
#define CIPHER_H
|
#define CIPHER_H
|
||||||
@ -96,10 +96,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 */
|
||||||
|
202
hostfile.c
202
hostfile.c
@ -14,63 +14,32 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#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 $");
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENSSL
|
||||||
|
#include <openssl/bn.h>
|
||||||
|
#include <openssl/rsa.h>
|
||||||
|
#include <openssl/dsa.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SSL
|
||||||
|
#include <ssl/bn.h>
|
||||||
|
#include <ssl/rsa.h>
|
||||||
|
#include <ssl/dsa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
|
#include "match.h"
|
||||||
#include "ssh.h"
|
#include "ssh.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 +54,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 +67,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 +101,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 +110,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 +153,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 +187,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
hostfile.h
Normal file
22
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
|
301
key.c
Normal file
301
key.c
Normal file
@ -0,0 +1,301 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Markus Friedl.
|
||||||
|
* 4. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* read_bignum():
|
||||||
|
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "includes.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENSSL
|
||||||
|
#include <openssl/bn.h>
|
||||||
|
#include <openssl/rsa.h>
|
||||||
|
#include <openssl/dsa.h>
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SSL
|
||||||
|
#include <ssl/bn.h>
|
||||||
|
#include <ssl/rsa.h>
|
||||||
|
#include <ssl/dsa.h>
|
||||||
|
#include <ssl/evp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ssh.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
#include "key.h"
|
||||||
|
|
||||||
|
Key *
|
||||||
|
key_new(int type)
|
||||||
|
{
|
||||||
|
Key *k;
|
||||||
|
RSA *rsa;
|
||||||
|
DSA *dsa;
|
||||||
|
k = xmalloc(sizeof(*k));
|
||||||
|
k->type = type;
|
||||||
|
switch (k->type) {
|
||||||
|
case KEY_RSA:
|
||||||
|
rsa = RSA_new();
|
||||||
|
rsa->n = BN_new();
|
||||||
|
rsa->e = BN_new();
|
||||||
|
k->rsa = rsa;
|
||||||
|
break;
|
||||||
|
case KEY_DSA:
|
||||||
|
dsa = DSA_new();
|
||||||
|
dsa->p = BN_new();
|
||||||
|
dsa->q = BN_new();
|
||||||
|
dsa->g = BN_new();
|
||||||
|
dsa->pub_key = BN_new();
|
||||||
|
k->dsa = dsa;
|
||||||
|
break;
|
||||||
|
case KEY_EMPTY:
|
||||||
|
k->dsa = NULL;
|
||||||
|
k->rsa = NULL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fatal("key_new: bad key type %d", k->type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
void
|
||||||
|
key_free(Key *k)
|
||||||
|
{
|
||||||
|
switch (k->type) {
|
||||||
|
case KEY_RSA:
|
||||||
|
if (k->rsa != NULL)
|
||||||
|
RSA_free(k->rsa);
|
||||||
|
k->rsa = NULL;
|
||||||
|
break;
|
||||||
|
case KEY_DSA:
|
||||||
|
if (k->dsa != NULL)
|
||||||
|
DSA_free(k->dsa);
|
||||||
|
k->dsa = NULL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fatal("key_free: bad key type %d", k->type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
xfree(k);
|
||||||
|
}
|
||||||
|
int
|
||||||
|
key_equal(Key *a, Key *b)
|
||||||
|
{
|
||||||
|
if (a == NULL || b == NULL || a->type != b->type)
|
||||||
|
return 0;
|
||||||
|
switch (a->type) {
|
||||||
|
case KEY_RSA:
|
||||||
|
return a->rsa != NULL && b->rsa != NULL &&
|
||||||
|
BN_cmp(a->rsa->e, b->rsa->e) == 0 &&
|
||||||
|
BN_cmp(a->rsa->n, b->rsa->n) == 0;
|
||||||
|
break;
|
||||||
|
case KEY_DSA:
|
||||||
|
return a->dsa != NULL && b->dsa != NULL &&
|
||||||
|
BN_cmp(a->dsa->p, b->dsa->p) == 0 &&
|
||||||
|
BN_cmp(a->dsa->q, b->dsa->q) == 0 &&
|
||||||
|
BN_cmp(a->dsa->g, b->dsa->g) == 0 &&
|
||||||
|
BN_cmp(a->dsa->pub_key, b->dsa->pub_key) == 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fatal("key_free: bad key type %d", a->type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FPRINT "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generate key fingerprint in ascii format.
|
||||||
|
* Based on ideas and code from Bjoern Groenvall <bg@sics.se>
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
key_fingerprint(Key *k)
|
||||||
|
{
|
||||||
|
static char retval[80];
|
||||||
|
unsigned char *buf = NULL;
|
||||||
|
int len = 0;
|
||||||
|
int nlen, elen, plen, qlen, glen, publen;
|
||||||
|
|
||||||
|
switch (k->type) {
|
||||||
|
case KEY_RSA:
|
||||||
|
nlen = BN_num_bytes(k->rsa->n);
|
||||||
|
elen = BN_num_bytes(k->rsa->e);
|
||||||
|
len = nlen + elen;
|
||||||
|
buf = xmalloc(len);
|
||||||
|
BN_bn2bin(k->rsa->n, buf);
|
||||||
|
BN_bn2bin(k->rsa->e, buf + nlen);
|
||||||
|
break;
|
||||||
|
case KEY_DSA:
|
||||||
|
plen = BN_num_bytes(k->dsa->p);
|
||||||
|
qlen = BN_num_bytes(k->dsa->q);
|
||||||
|
glen = BN_num_bytes(k->dsa->g);
|
||||||
|
publen = BN_num_bytes(k->dsa->pub_key);
|
||||||
|
len = qlen + qlen + glen + publen;
|
||||||
|
buf = xmalloc(len);
|
||||||
|
BN_bn2bin(k->dsa->p, buf);
|
||||||
|
BN_bn2bin(k->dsa->q, buf + plen);
|
||||||
|
BN_bn2bin(k->dsa->g, buf + plen + qlen);
|
||||||
|
BN_bn2bin(k->dsa->pub_key , buf + plen + qlen + glen);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fatal("key_fingerprint: bad key type %d", k->type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (buf != NULL) {
|
||||||
|
unsigned char d[16];
|
||||||
|
EVP_MD_CTX md;
|
||||||
|
EVP_DigestInit(&md, EVP_md5());
|
||||||
|
EVP_DigestUpdate(&md, buf, len);
|
||||||
|
EVP_DigestFinal(&md, d, NULL);
|
||||||
|
snprintf(retval, sizeof(retval), FPRINT,
|
||||||
|
d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],
|
||||||
|
d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
|
||||||
|
memset(buf, 0, len);
|
||||||
|
xfree(buf);
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reads a multiple-precision integer in decimal from the buffer, and advances
|
||||||
|
* the pointer. The integer must already be initialized. This function is
|
||||||
|
* permitted to modify the buffer. This leaves *cpp to point just beyond the
|
||||||
|
* last processed (and maybe modified) character. Note that this may modify
|
||||||
|
* the buffer containing the number.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
read_bignum(char **cpp, BIGNUM * value)
|
||||||
|
{
|
||||||
|
char *cp = *cpp;
|
||||||
|
int old;
|
||||||
|
|
||||||
|
/* Skip any leading whitespace. */
|
||||||
|
for (; *cp == ' ' || *cp == '\t'; cp++)
|
||||||
|
;
|
||||||
|
|
||||||
|
/* Check that it begins with a decimal digit. */
|
||||||
|
if (*cp < '0' || *cp > '9')
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Save starting position. */
|
||||||
|
*cpp = cp;
|
||||||
|
|
||||||
|
/* Move forward until all decimal digits skipped. */
|
||||||
|
for (; *cp >= '0' && *cp <= '9'; cp++)
|
||||||
|
;
|
||||||
|
|
||||||
|
/* Save the old terminating character, and replace it by \0. */
|
||||||
|
old = *cp;
|
||||||
|
*cp = 0;
|
||||||
|
|
||||||
|
/* Parse the number. */
|
||||||
|
if (BN_dec2bn(&value, *cpp) == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Restore old terminating character. */
|
||||||
|
*cp = old;
|
||||||
|
|
||||||
|
/* Move beyond the number and return success. */
|
||||||
|
*cpp = cp;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int
|
||||||
|
write_bignum(FILE *f, BIGNUM *num)
|
||||||
|
{
|
||||||
|
char *buf = BN_bn2dec(num);
|
||||||
|
if (buf == NULL) {
|
||||||
|
error("write_bignum: BN_bn2dec() failed");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
fprintf(f, " %s", buf);
|
||||||
|
free(buf);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int
|
||||||
|
key_read(Key *ret, unsigned int bits, char **cpp)
|
||||||
|
{
|
||||||
|
switch(ret->type) {
|
||||||
|
case KEY_RSA:
|
||||||
|
if (bits == 0)
|
||||||
|
return 0;
|
||||||
|
/* Get public exponent, public modulus. */
|
||||||
|
if (!read_bignum(cpp, ret->rsa->e))
|
||||||
|
return 0;
|
||||||
|
if (!read_bignum(cpp, ret->rsa->n))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case KEY_DSA:
|
||||||
|
if (bits != 0)
|
||||||
|
return 0;
|
||||||
|
if (!read_bignum(cpp, ret->dsa->p))
|
||||||
|
return 0;
|
||||||
|
if (!read_bignum(cpp, ret->dsa->q))
|
||||||
|
return 0;
|
||||||
|
if (!read_bignum(cpp, ret->dsa->g))
|
||||||
|
return 0;
|
||||||
|
if (!read_bignum(cpp, ret->dsa->pub_key))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fatal("bad key type: %d", ret->type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int
|
||||||
|
key_write(Key *key, FILE *f)
|
||||||
|
{
|
||||||
|
int success = 0;
|
||||||
|
unsigned int bits = 0;
|
||||||
|
|
||||||
|
if (key->type == KEY_RSA && key->rsa != NULL) {
|
||||||
|
/* size of modulus 'n' */
|
||||||
|
bits = BN_num_bits(key->rsa->n);
|
||||||
|
fprintf(f, "%u", bits);
|
||||||
|
if (write_bignum(f, key->rsa->e) &&
|
||||||
|
write_bignum(f, key->rsa->n)) {
|
||||||
|
success = 1;
|
||||||
|
} else {
|
||||||
|
error("key_write: failed for RSA key");
|
||||||
|
}
|
||||||
|
} else if (key->type == KEY_DSA && key->dsa != NULL) {
|
||||||
|
/* bits == 0 means DSA key */
|
||||||
|
bits = 0;
|
||||||
|
fprintf(f, "%u", bits);
|
||||||
|
if (write_bignum(f, key->dsa->p) &&
|
||||||
|
write_bignum(f, key->dsa->q) &&
|
||||||
|
write_bignum(f, key->dsa->g) &&
|
||||||
|
write_bignum(f, key->dsa->pub_key)) {
|
||||||
|
success = 1;
|
||||||
|
} else {
|
||||||
|
error("key_write: failed for DSA key");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
23
key.h
Normal file
23
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
|
61
match.c
61
match.c
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$Id: match.c,v 1.3 1999/11/25 00:54:59 damien Exp $");
|
RCSID("$Id: match.c,v 1.4 2000/03/26 03:04:53 damien Exp $");
|
||||||
|
|
||||||
#include "ssh.h"
|
#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
match.h
Normal file
18
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
|
29
scp.1
29
scp.1
@ -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/20 12:13:36 damien Exp $
|
.\" $Id: scp.1,v 1.6 2000/03/26 03:04:53 damien 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
|
||||||
|
31
ssh-add.1
31
ssh-add.1
@ -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.9 2000/01/22 08:57:40 damien Exp $
|
.\" $Id: ssh-add.1,v 1.10 2000/03/26 03:04:53 damien Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd September 25, 1999
|
.Dd September 25, 1999
|
||||||
.Dt SSH-ADD 1
|
.Dt SSH-ADD 1
|
||||||
@ -27,8 +27,8 @@ 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.
|
||||||
@ -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
|
||||||
|
52
ssh-agent.1
52
ssh-agent.1
@ -1,4 +1,4 @@
|
|||||||
.\" $OpenBSD: ssh-agent.1,v 1.9 2000/01/22 02:17:50 aaron Exp $
|
.\" $OpenBSD: ssh-agent.1,v 1.10 2000/03/23 21:10:10 aaron Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" -*- nroff -*-
|
.\" -*- 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
|
||||||
|
62
ssh-keygen.1
62
ssh-keygen.1
@ -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.9 2000/01/22 08:57:40 damien Exp $
|
.\" $Id: ssh-keygen.1,v 1.10 2000/03/26 03:04:53 damien Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd September 25, 1999
|
.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
|
||||||
|
34
ssh.1
34
ssh.1
@ -9,7 +9,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" Created: Sat Apr 22 21:55:14 1995 ylo
|
.\" Created: Sat Apr 22 21:55:14 1995 ylo
|
||||||
.\"
|
.\"
|
||||||
.\" $Id: ssh.1,v 1.19 2000/03/17 12:40:17 damien Exp $
|
.\" $Id: ssh.1,v 1.20 2000/03/26 03:04:54 damien Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd September 25, 1999
|
.Dd September 25, 1999
|
||||||
.Dt SSH 1
|
.Dt SSH 1
|
||||||
@ -287,8 +287,8 @@ host key is not known or has changed.
|
|||||||
.Sh OPTIONS
|
.Sh OPTIONS
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Fl a
|
.It Fl a
|
||||||
Disables forwarding of the authentication agent connection. This may
|
Disables forwarding of the authentication agent connection.
|
||||||
also be specified on a per-host basis in the configuration file.
|
This may also be specified on a per-host basis in the configuration file.
|
||||||
.It Fl c Ar blowfish|3des
|
.It Fl c Ar blowfish|3des
|
||||||
Selects the cipher to use for encrypting the session.
|
Selects the cipher to use for encrypting the session.
|
||||||
.Ar 3des
|
.Ar 3des
|
||||||
@ -342,8 +342,8 @@ It is possible to have multiple
|
|||||||
options (and multiple identities specified in
|
options (and multiple identities specified in
|
||||||
configuration files).
|
configuration files).
|
||||||
.It Fl k
|
.It Fl k
|
||||||
Disables forwarding of Kerberos tickets and AFS tokens. This may
|
Disables forwarding of Kerberos tickets and AFS tokens.
|
||||||
also be specified on a per-host basis in the configuration file.
|
This may also be specified on a per-host basis in the configuration file.
|
||||||
.It Fl l Ar login_name
|
.It Fl l Ar login_name
|
||||||
Specifies the user to log in as on the remote machine.
|
Specifies the user to log in as on the remote machine.
|
||||||
This also may be specified on a per-host basis in the configuration file.
|
This also may be specified on a per-host basis in the configuration file.
|
||||||
@ -390,7 +390,7 @@ Causes all warning and diagnostic messages to be suppressed.
|
|||||||
Only fatal errors are displayed.
|
Only fatal errors are displayed.
|
||||||
.It Fl t
|
.It Fl t
|
||||||
Force pseudo-tty allocation.
|
Force pseudo-tty allocation.
|
||||||
This can be used to execute arbitary
|
This can be used to execute arbitrary
|
||||||
screen-based programs on a remote machine, which can be very useful,
|
screen-based programs on a remote machine, which can be very useful,
|
||||||
e.g., when implementing menu services.
|
e.g., when implementing menu services.
|
||||||
.It Fl v
|
.It Fl v
|
||||||
@ -514,8 +514,8 @@ The host is the
|
|||||||
argument given on the command line (i.e., the name is not converted to
|
argument given on the command line (i.e., the name is not converted to
|
||||||
a canonicalized host name before matching).
|
a canonicalized host name before matching).
|
||||||
.It Cm AFSTokenPassing
|
.It Cm AFSTokenPassing
|
||||||
Specifies whether to pass AFS tokens to remote host. The argument to
|
Specifies whether to pass AFS tokens to remote host.
|
||||||
this keyword must be
|
The argument to this keyword must be
|
||||||
.Dq yes
|
.Dq yes
|
||||||
or
|
or
|
||||||
.Dq no .
|
.Dq no .
|
||||||
@ -534,7 +534,8 @@ If this flag is set to
|
|||||||
.Dq yes ,
|
.Dq yes ,
|
||||||
ssh will additionally check the host ip address in the
|
ssh will additionally check the host ip address in the
|
||||||
.Pa known_hosts
|
.Pa known_hosts
|
||||||
file. This allows ssh to detect if a host key changed due to DNS spoofing.
|
file.
|
||||||
|
This allows ssh to detect if a host key changed due to DNS spoofing.
|
||||||
If the option is set to
|
If the option is set to
|
||||||
.Dq no ,
|
.Dq no ,
|
||||||
the check will not be executed.
|
the check will not be executed.
|
||||||
@ -657,15 +658,15 @@ 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 will be used. The argument to
|
Specifies whether Kerberos authentication will be used.
|
||||||
this keyword must be
|
The argument to this keyword must be
|
||||||
.Dq yes
|
.Dq yes
|
||||||
or
|
or
|
||||||
.Dq no .
|
.Dq no .
|
||||||
.It Cm KerberosTgtPassing
|
.It Cm KerberosTgtPassing
|
||||||
Specifies whether a Kerberos TGT will be forwarded to the server. This
|
Specifies whether a Kerberos TGT will be forwarded to the server.
|
||||||
will only work if the Kerberos server is actually an AFS kaserver. The
|
This will only work if the Kerberos server is actually an AFS kaserver.
|
||||||
argument to this keyword must be
|
The argument to this keyword must be
|
||||||
.Dq yes
|
.Dq yes
|
||||||
or
|
or
|
||||||
.Dq no .
|
.Dq no .
|
||||||
@ -684,8 +685,9 @@ The possible values are:
|
|||||||
QUIET, FATAL, ERROR, INFO, VERBOSE and DEBUG.
|
QUIET, FATAL, ERROR, INFO, VERBOSE and DEBUG.
|
||||||
The default is INFO.
|
The default is INFO.
|
||||||
.It Cm NumberOfPasswordPrompts
|
.It Cm NumberOfPasswordPrompts
|
||||||
Specifies the number of password prompts before giving up. The
|
Specifies the number of password prompts before giving up.
|
||||||
argument to this keyword must be an integer. Default is 3.
|
The argument to this keyword must be an integer.
|
||||||
|
Default is 3.
|
||||||
.It Cm PasswordAuthentication
|
.It Cm PasswordAuthentication
|
||||||
Specifies whether to use password authentication.
|
Specifies whether to use password authentication.
|
||||||
The argument to this keyword must be
|
The argument to this keyword must be
|
||||||
|
13
ssh.c
13
ssh.c
@ -11,7 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$Id: ssh.c,v 1.21 2000/03/09 10:27:52 damien Exp $");
|
RCSID("$Id: ssh.c,v 1.22 2000/03/26 03:04:54 damien Exp $");
|
||||||
|
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
#include "ssh.h"
|
#include "ssh.h"
|
||||||
@ -181,6 +181,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;
|
||||||
|
|
||||||
@ -618,9 +619,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);
|
||||||
@ -672,9 +670,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.");
|
||||||
@ -802,7 +801,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();
|
||||||
|
36
ssh.h
36
ssh.h
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* RCSID("$Id: ssh.h,v 1.27 2000/03/09 10:27:52 damien Exp $"); */
|
/* RCSID("$Id: ssh.h,v 1.28 2000/03/26 03:04:54 damien Exp $"); */
|
||||||
|
|
||||||
#ifndef SSH_H
|
#ifndef SSH_H
|
||||||
#define SSH_H
|
#define SSH_H
|
||||||
@ -338,8 +338,7 @@ int auth_rhosts(struct passwd * pw, const char *client_user);
|
|||||||
* its host key. Returns true if authentication succeeds.
|
* 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
|
||||||
@ -387,41 +386,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
|
||||||
|
72
sshconnect.c
72
sshconnect.c
@ -8,15 +8,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: sshconnect.c,v 1.57 2000/03/16 20:56:14 markus Exp $");
|
RCSID("$OpenBSD: sshconnect.c,v 1.58 2000/03/23 22:15:33 markus Exp $");
|
||||||
|
|
||||||
#ifdef HAVE_OPENSSL
|
#ifdef HAVE_OPENSSL
|
||||||
#include <openssl/bn.h>
|
#include <openssl/rsa.h>
|
||||||
|
#include <openssl/dsa.h>
|
||||||
#include <openssl/md5.h>
|
#include <openssl/md5.h>
|
||||||
|
#include <openssl/bn.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_SSL
|
||||||
#include <ssl/bn.h>
|
#include <ssl/rsa.h>
|
||||||
|
#include <ssl/dsa.h>
|
||||||
#include <ssl/md5.h>
|
#include <ssl/md5.h>
|
||||||
|
#include <ssl/bn.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
@ -29,7 +33,8 @@ RCSID("$OpenBSD: sshconnect.c,v 1.57 2000/03/16 20:56:14 markus Exp $");
|
|||||||
#include "uidswap.h"
|
#include "uidswap.h"
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "readconf.h"
|
#include "readconf.h"
|
||||||
#include "fingerprint.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];
|
||||||
@ -1073,9 +1078,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;
|
||||||
@ -1129,47 +1134,34 @@ check_host_key(char *host, struct sockaddr *hostaddr, RSA *host_key)
|
|||||||
* Store the host key from the known host file in here so that we can
|
* 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:
|
||||||
@ -1177,8 +1169,7 @@ check_host_key(char *host, struct sockaddr *hostaddr, RSA *host_key)
|
|||||||
debug("Host '%.200s' is known and matches the host key.", host);
|
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
|
||||||
@ -1198,12 +1189,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");
|
||||||
}
|
}
|
||||||
@ -1214,8 +1205,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
|
||||||
@ -1283,6 +1273,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
|
||||||
@ -1358,7 +1356,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;
|
||||||
|
|
||||||
@ -1617,7 +1615,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
|
||||||
@ -1648,6 +1645,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);
|
||||||
}
|
}
|
||||||
|
386
sshd.8
386
sshd.8
@ -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.14 2000/03/17 12:40:18 damien Exp $
|
.\" $Id: sshd.8,v 1.15 2000/03/26 03:04:55 damien Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd September 25, 1999
|
.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 ) .
|
||||||
@ -266,7 +290,8 @@ 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.
|
||||||
|
The default is
|
||||||
.Dq yes .
|
.Dq yes .
|
||||||
.It Cm IgnoreUserKnownHosts
|
.It Cm IgnoreUserKnownHosts
|
||||||
Specifies whether
|
Specifies whether
|
||||||
@ -279,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.
|
||||||
@ -290,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.
|
||||||
@ -317,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
|
||||||
@ -337,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
|
||||||
@ -353,8 +387,8 @@ 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 no .
|
.Dq no .
|
||||||
.It Cm PermitRootLogin
|
.It Cm PermitRootLogin
|
||||||
Specifies whether the root can log in using
|
Specifies whether the root can log in using
|
||||||
@ -379,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
|
||||||
@ -405,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.
|
||||||
|
The default is
|
||||||
.Dq no .
|
.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
|
||||||
@ -425,29 +465,34 @@ 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.
|
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.
|
||||||
|
The default is
|
||||||
.Dq no .
|
.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.
|
||||||
@ -489,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.
|
||||||
@ -500,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
|
||||||
@ -513,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
|
||||||
@ -576,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
|
||||||
@ -604,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
|
||||||
@ -636,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
|
||||||
@ -646,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
|
||||||
@ -668,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
|
||||||
@ -678,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
|
||||||
@ -696,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"
|
||||||
@ -718,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.
|
||||||
@ -729,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
|
||||||
@ -763,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
|
||||||
|
30
sshd.c
30
sshd.c
@ -11,7 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: sshd.c,v 1.92 2000/03/16 20:56:15 markus Exp $");
|
RCSID("$OpenBSD: sshd.c,v 1.94 2000/03/23 22:15:34 markus Exp $");
|
||||||
|
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
#include "rsa.h"
|
#include "rsa.h"
|
||||||
@ -516,9 +516,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;
|
||||||
@ -1301,7 +1298,7 @@ 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 = NULL, *password = NULL;
|
char *client_user = NULL, *password = NULL;
|
||||||
char user[1024];
|
char user[1024];
|
||||||
@ -1417,21 +1414,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);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user