version 1.17, 2000/06/20 01:39:44 |
version 1.18, 2000/07/16 08:27:21 |
|
|
#include "rsa.h" |
#include "rsa.h" |
#include "ssh.h" |
#include "ssh.h" |
#include "xmalloc.h" |
#include "xmalloc.h" |
#include "authfd.h" |
|
#include "fingerprint.h" |
#include "fingerprint.h" |
#include "key.h" |
#include "key.h" |
|
#include "authfd.h" |
#include "authfile.h" |
#include "authfile.h" |
|
|
void |
void |
|
|
char buf[1024], msg[1024]; |
char buf[1024], msg[1024]; |
int success; |
int success; |
int interactive = isatty(STDIN_FILENO); |
int interactive = isatty(STDIN_FILENO); |
|
int type = KEY_RSA; |
|
|
|
/* |
|
* try to load the public key. right now this only works for RSA, |
|
* since DSA keys are fully encrypted |
|
*/ |
public = key_new(KEY_RSA); |
public = key_new(KEY_RSA); |
if (!load_public_key(filename, public, &saved_comment)) { |
if (!load_public_key(filename, public, &saved_comment)) { |
printf("Bad key file %s: %s\n", filename, strerror(errno)); |
/* ok, so we will asume this is a DSA key */ |
return; |
type = KEY_DSA; |
|
saved_comment = xstrdup(filename); |
} |
} |
key_free(public); |
key_free(public); |
|
|
|
|
} |
} |
|
|
/* At first, try empty passphrase */ |
/* At first, try empty passphrase */ |
private = key_new(KEY_RSA); |
private = key_new(type); |
success = load_private_key(filename, "", private, &comment); |
success = load_private_key(filename, "", private, &comment); |
if (!success) { |
if (!success) { |
printf("Need passphrase for %.200s\n", filename); |
printf("Need passphrase for %.200s\n", filename); |
|
|
} |
} |
xfree(saved_comment); |
xfree(saved_comment); |
|
|
if (ssh_add_identity(ac, private->rsa, comment)) |
if (ssh_add_identity(ac, private, comment)) |
fprintf(stderr, "Identity added: %s (%s)\n", filename, comment); |
fprintf(stderr, "Identity added: %s (%s)\n", filename, comment); |
else |
else |
fprintf(stderr, "Could not add identity: %s\n", filename); |
fprintf(stderr, "Could not add identity: %s\n", filename); |