version 1.102, 2015/10/24 22:56:19 |
version 1.103, 2015/11/08 22:30:20 |
|
|
#define KT_ECDSA 8 |
#define KT_ECDSA 8 |
#define KT_ED25519 16 |
#define KT_ED25519 16 |
|
|
|
int get_cert = 0; |
int get_keytypes = KT_RSA|KT_ECDSA|KT_ED25519; |
int get_keytypes = KT_RSA|KT_ECDSA|KT_ED25519; |
|
|
int hash_hosts = 0; /* Hash hostname on output */ |
int hash_hosts = 0; /* Hash hostname on output */ |
|
|
int r; |
int r; |
|
|
enable_compat20(); |
enable_compat20(); |
myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = |
switch (c->c_keytype) { |
c->c_keytype == KT_DSA ? "ssh-dss" : |
case KT_DSA: |
(c->c_keytype == KT_RSA ? "ssh-rsa" : |
myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = get_cert ? |
(c->c_keytype == KT_ED25519 ? "ssh-ed25519" : |
"ssh-dss-cert-v01@openssh.com" : "ssh-dss"; |
"ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521")); |
break; |
|
case KT_RSA: |
|
myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = get_cert ? |
|
"ssh-rsa-cert-v01@openssh.com" : "ssh-rsa"; |
|
break; |
|
case KT_ED25519: |
|
myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = get_cert ? |
|
"ssh-ed25519-cert-v01@openssh.com" : "ssh-ed25519"; |
|
break; |
|
case KT_ECDSA: |
|
myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = get_cert ? |
|
"ecdsa-sha2-nistp256-cert-v01@openssh.com," |
|
"ecdsa-sha2-nistp384-cert-v01@openssh.com," |
|
"ecdsa-sha2-nistp521-cert-v01@openssh.com" : |
|
"ecdsa-sha2-nistp256," |
|
"ecdsa-sha2-nistp384," |
|
"ecdsa-sha2-nistp521"; |
|
break; |
|
default: |
|
fatal("unknown key type %d", c->c_keytype); |
|
break; |
|
} |
if ((r = kex_setup(c->c_ssh, myproposal)) != 0) { |
if ((r = kex_setup(c->c_ssh, myproposal)) != 0) { |
free(c->c_ssh); |
free(c->c_ssh); |
fprintf(stderr, "kex_setup: %s\n", ssh_err(r)); |
fprintf(stderr, "kex_setup: %s\n", ssh_err(r)); |
|
|
fatal("host_hash failed"); |
fatal("host_hash failed"); |
|
|
hostport = put_host_port(host, ssh_port); |
hostport = put_host_port(host, ssh_port); |
fprintf(stdout, "%s ", hostport); |
if (!get_cert) |
|
fprintf(stdout, "%s ", hostport); |
sshkey_write(key, stdout); |
sshkey_write(key, stdout); |
fputs("\n", stdout); |
fputs("\n", stdout); |
free(hostport); |
free(hostport); |
|
|
|
|
if (key == NULL) |
if (key == NULL) |
return; |
return; |
if (!hash_hosts && ssh_port == SSH_DEFAULT_PORT) { |
if (get_cert || (!hash_hosts && ssh_port == SSH_DEFAULT_PORT)) { |
keyprint_one(hosts, key); |
keyprint_one(hosts, key); |
return; |
return; |
} |
} |
|
|
if (fdcon[s].c_status) |
if (fdcon[s].c_status) |
fatal("conalloc: attempt to reuse fdno %d", s); |
fatal("conalloc: attempt to reuse fdno %d", s); |
|
|
|
debug3("%s: oname %s kt %d", __func__, oname, keytype); |
fdcon[s].c_fd = s; |
fdcon[s].c_fd = s; |
fdcon[s].c_status = CS_CON; |
fdcon[s].c_status = CS_CON; |
fdcon[s].c_namebase = namebase; |
fdcon[s].c_namebase = namebase; |
|
|
usage(void) |
usage(void) |
{ |
{ |
fprintf(stderr, |
fprintf(stderr, |
"usage: %s [-46Hv] [-f file] [-p port] [-T timeout] [-t type]\n" |
"usage: %s [-46Hcv] [-f file] [-p port] [-T timeout] [-t type]\n" |
"\t\t [host | addrlist namelist] ...\n", |
"\t\t [host | addrlist namelist] ...\n", |
__progname); |
__progname); |
exit(1); |
exit(1); |
|
|
if (argc <= 1) |
if (argc <= 1) |
usage(); |
usage(); |
|
|
while ((opt = getopt(argc, argv, "Hv46p:T:t:f:")) != -1) { |
while ((opt = getopt(argc, argv, "cHv46p:T:t:f:")) != -1) { |
switch (opt) { |
switch (opt) { |
case 'H': |
case 'H': |
hash_hosts = 1; |
hash_hosts = 1; |
|
break; |
|
case 'c': |
|
get_cert = 1; |
break; |
break; |
case 'p': |
case 'p': |
ssh_port = a2port(optarg); |
ssh_port = a2port(optarg); |