mirror of
https://github.com/tmate-io/tmate.git
synced 2025-02-02 19:39:32 +01:00
Allow users to specify their own tmate servers
Options: - tmate-server-host - tmate-server-port - tmate-server-dsa-fingerprint - tmate-server-rsa-fingerprint - tmate-server-ecdsa-fingerprint
This commit is contained in:
parent
bb5634ce20
commit
0d182e707e
@ -25,10 +25,6 @@ CFLAGS += -Wno-unused-parameter -Wno-unused-variable
|
|||||||
CFLAGS += -Ilibssh/include/ -Imsgpack/src
|
CFLAGS += -Ilibssh/include/ -Imsgpack/src
|
||||||
CFLAGS += -rdynamic # for stack traces
|
CFLAGS += -rdynamic # for stack traces
|
||||||
|
|
||||||
if IS_DEVENV
|
|
||||||
CFLAGS += -DDEVENV
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Set flags for gcc. gcc4 whines abouts silly stuff so it needs slightly
|
# Set flags for gcc. gcc4 whines abouts silly stuff so it needs slightly
|
||||||
# different flags.
|
# different flags.
|
||||||
if IS_GCC
|
if IS_GCC
|
||||||
|
@ -40,13 +40,6 @@ AC_CHECK_HEADERS(
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
AC_ARG_ENABLE(
|
|
||||||
devenv,
|
|
||||||
AC_HELP_STRING(--enable-devenv, "dev env (localhost, port 2200, no auth checks)"),
|
|
||||||
found_devenv=$enable_devenv
|
|
||||||
)
|
|
||||||
AM_CONDITIONAL(IS_DEVENV, test "x$found_devenv" = xyes)
|
|
||||||
|
|
||||||
# Is this a debug build?
|
# Is this a debug build?
|
||||||
#found_debug=yes
|
#found_debug=yes
|
||||||
AC_ARG_ENABLE(
|
AC_ARG_ENABLE(
|
||||||
|
@ -169,18 +169,6 @@ const struct options_table_entry session_options_table[] = {
|
|||||||
.default_num = 750
|
.default_num = 750
|
||||||
},
|
},
|
||||||
|
|
||||||
{ .name = "tmate-display-time",
|
|
||||||
.type = OPTIONS_TABLE_NUMBER,
|
|
||||||
.minimum = 1,
|
|
||||||
.maximum = INT_MAX,
|
|
||||||
.default_num = 30000
|
|
||||||
},
|
|
||||||
|
|
||||||
{ .name = "tmate-identity",
|
|
||||||
.type = OPTIONS_TABLE_STRING,
|
|
||||||
.default_str = ""
|
|
||||||
},
|
|
||||||
|
|
||||||
{ .name = "history-limit",
|
{ .name = "history-limit",
|
||||||
.type = OPTIONS_TABLE_NUMBER,
|
.type = OPTIONS_TABLE_NUMBER,
|
||||||
.minimum = 0,
|
.minimum = 0,
|
||||||
@ -463,6 +451,46 @@ const struct options_table_entry session_options_table[] = {
|
|||||||
.default_str = " -_@"
|
.default_str = " -_@"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{ .name = "tmate-display-time",
|
||||||
|
.type = OPTIONS_TABLE_NUMBER,
|
||||||
|
.minimum = 1,
|
||||||
|
.maximum = INT_MAX,
|
||||||
|
.default_num = 30000
|
||||||
|
},
|
||||||
|
|
||||||
|
{ .name = "tmate-identity",
|
||||||
|
.type = OPTIONS_TABLE_STRING,
|
||||||
|
.default_str = ""
|
||||||
|
},
|
||||||
|
|
||||||
|
{ .name = "tmate-server-host",
|
||||||
|
.type = OPTIONS_TABLE_STRING,
|
||||||
|
.default_str = "master.tmate.io"
|
||||||
|
},
|
||||||
|
|
||||||
|
{ .name = "tmate-server-port",
|
||||||
|
.type = OPTIONS_TABLE_NUMBER,
|
||||||
|
.minimum = 1,
|
||||||
|
.maximum = 65535,
|
||||||
|
.default_num = 22
|
||||||
|
},
|
||||||
|
|
||||||
|
{ .name = "tmate-server-dsa-fingerprint",
|
||||||
|
.type = OPTIONS_TABLE_STRING,
|
||||||
|
.default_str = "f5:26:31:c3:8a:78:6e:5c:77:74:0f:41:5b:5f:21:88"
|
||||||
|
},
|
||||||
|
|
||||||
|
{ .name = "tmate-server-rsa-fingerprint",
|
||||||
|
.type = OPTIONS_TABLE_STRING,
|
||||||
|
.default_str = "af:2d:81:c1:fe:49:70:2d:7f:09:a9:d7:4b:32:e3:be"
|
||||||
|
},
|
||||||
|
|
||||||
|
{ .name = "tmate-server-ecdsa-fingerprint",
|
||||||
|
.type = OPTIONS_TABLE_STRING,
|
||||||
|
.default_str = "c7:a1:51:36:d2:bb:35:4b:0a:1a:c0:43:97:74:ea:42"
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
{ .name = NULL }
|
{ .name = NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,10 +29,11 @@ static void dns_cb(int errcode, struct evutil_addrinfo *addr, void *ptr)
|
|||||||
struct tmate_ssh_client *client;
|
struct tmate_ssh_client *client;
|
||||||
struct evutil_addrinfo *ai;
|
struct evutil_addrinfo *ai;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
const char *host = ptr;
|
||||||
|
|
||||||
if (errcode) {
|
if (errcode) {
|
||||||
tmate_status_message("%s lookup failure. Retrying in %d seconds (%s)",
|
tmate_status_message("%s lookup failure. Retrying in %d seconds (%s)",
|
||||||
TMATE_HOST, TMATE_DNS_RETRY_TIMEOUT,
|
host, TMATE_DNS_RETRY_TIMEOUT,
|
||||||
evutil_gai_strerror(errcode));
|
evutil_gai_strerror(errcode));
|
||||||
|
|
||||||
tv.tv_sec = TMATE_DNS_RETRY_TIMEOUT;
|
tv.tv_sec = TMATE_DNS_RETRY_TIMEOUT;
|
||||||
@ -44,7 +45,7 @@ static void dns_cb(int errcode, struct evutil_addrinfo *addr, void *ptr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmate_status_message("Connecting to %s...", TMATE_HOST);
|
tmate_status_message("Connecting to %s...", host);
|
||||||
|
|
||||||
for (ai = addr; ai; ai = ai->ai_next) {
|
for (ai = addr; ai; ai = ai->ai_next) {
|
||||||
char buf[128];
|
char buf[128];
|
||||||
@ -79,6 +80,7 @@ static void dns_cb(int errcode, struct evutil_addrinfo *addr, void *ptr)
|
|||||||
static void lookup_and_connect(void)
|
static void lookup_and_connect(void)
|
||||||
{
|
{
|
||||||
struct evutil_addrinfo hints;
|
struct evutil_addrinfo hints;
|
||||||
|
const char *tmate_server_host;
|
||||||
|
|
||||||
if (!ev_dnsbase)
|
if (!ev_dnsbase)
|
||||||
ev_dnsbase = evdns_base_new(ev_base, 1);
|
ev_dnsbase = evdns_base_new(ev_base, 1);
|
||||||
@ -91,9 +93,11 @@ static void lookup_and_connect(void)
|
|||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
hints.ai_protocol = IPPROTO_TCP;
|
hints.ai_protocol = IPPROTO_TCP;
|
||||||
|
|
||||||
tmate_info("Looking up %s...", TMATE_HOST);
|
tmate_server_host = options_get_string(&global_s_options,
|
||||||
(void)evdns_getaddrinfo(ev_dnsbase, TMATE_HOST, NULL,
|
"tmate-server-host");
|
||||||
&hints, dns_cb, NULL);
|
tmate_info("Looking up %s...", tmate_server_host);
|
||||||
|
(void)evdns_getaddrinfo(ev_dnsbase, tmate_server_host, NULL,
|
||||||
|
&hints, dns_cb, tmate_server_host);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmate_session_init(void)
|
void tmate_session_init(void)
|
||||||
|
@ -168,10 +168,11 @@ static void on_session_event(struct tmate_ssh_client *client)
|
|||||||
unsigned char *hash;
|
unsigned char *hash;
|
||||||
ssize_t hash_len;
|
ssize_t hash_len;
|
||||||
char *hash_str;
|
char *hash_str;
|
||||||
|
char *server_hash_str;
|
||||||
int match;
|
int match;
|
||||||
|
|
||||||
int verbosity = SSH_LOG_NOLOG + debug_level;
|
int verbosity = SSH_LOG_NOLOG + debug_level;
|
||||||
int port = TMATE_PORT;
|
int port = options_get_number(&global_s_options, "tmate-server-port");
|
||||||
|
|
||||||
ssh_session session = client->session;
|
ssh_session session = client->session;
|
||||||
ssh_channel channel = client->channel;
|
ssh_channel channel = client->channel;
|
||||||
@ -241,24 +242,26 @@ static void on_session_event(struct tmate_ssh_client *client)
|
|||||||
if (ssh_get_publickey(session, &pubkey) < 0)
|
if (ssh_get_publickey(session, &pubkey) < 0)
|
||||||
tmate_fatal("ssh_get_publickey");
|
tmate_fatal("ssh_get_publickey");
|
||||||
|
|
||||||
#ifdef DEVENV
|
|
||||||
match = 1;
|
|
||||||
#else
|
|
||||||
key_type = ssh_key_type(pubkey);
|
key_type = ssh_key_type(pubkey);
|
||||||
|
|
||||||
switch (key_type) {
|
switch (key_type) {
|
||||||
case SSH_KEYTYPE_DSS:
|
case SSH_KEYTYPE_DSS:
|
||||||
match = !strcmp(hash_str, TMATE_HOST_DSA_KEY);
|
server_hash_str = options_get_string(&global_s_options,
|
||||||
|
"tmate-server-dsa-fingerprint");
|
||||||
break;
|
break;
|
||||||
case SSH_KEYTYPE_RSA:
|
case SSH_KEYTYPE_RSA:
|
||||||
match = !strcmp(hash_str, TMATE_HOST_RSA_KEY);
|
server_hash_str = options_get_string(&global_s_options,
|
||||||
|
"tmate-server-rsa-fingerprint");
|
||||||
break;
|
break;
|
||||||
case SSH_KEYTYPE_ECDSA:
|
case SSH_KEYTYPE_ECDSA:
|
||||||
match = !strcmp(hash_str, TMATE_HOST_ECDSA_KEY);
|
server_hash_str = options_get_string(&global_s_options,
|
||||||
|
"tmate-server-ecdsa-fingerprint");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
match = 0;
|
server_hash_str = "";
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
match = !strcmp(hash_str, server_hash_str);
|
||||||
|
|
||||||
ssh_key_free(pubkey);
|
ssh_key_free(pubkey);
|
||||||
ssh_clean_pubkey_hash(&hash);
|
ssh_clean_pubkey_hash(&hash);
|
||||||
|
11
tmate.h
11
tmate.h
@ -72,17 +72,6 @@ extern void tmate_decoder_commit(struct tmate_decoder *decoder, size_t len);
|
|||||||
|
|
||||||
/* tmate-ssh-client.c */
|
/* tmate-ssh-client.c */
|
||||||
|
|
||||||
#ifdef DEVENV
|
|
||||||
#define TMATE_HOST "localhost"
|
|
||||||
#define TMATE_PORT 2200
|
|
||||||
#else
|
|
||||||
#define TMATE_HOST "master.tmate.io"
|
|
||||||
#define TMATE_PORT 22
|
|
||||||
#define TMATE_HOST_DSA_KEY "f5:26:31:c3:8a:78:6e:5c:77:74:0f:41:5b:5f:21:88"
|
|
||||||
#define TMATE_HOST_RSA_KEY "af:2d:81:c1:fe:49:70:2d:7f:09:a9:d7:4b:32:e3:be"
|
|
||||||
#define TMATE_HOST_ECDSA_KEY "c7:a1:51:36:d2:bb:35:4b:0a:1a:c0:43:97:74:ea:42"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum tmate_ssh_client_state_types {
|
enum tmate_ssh_client_state_types {
|
||||||
SSH_NONE,
|
SSH_NONE,
|
||||||
SSH_INIT,
|
SSH_INIT,
|
||||||
|
Loading…
Reference in New Issue
Block a user