1
0
mirror of https://github.com/tmate-io/tmate-ssh-server.git synced 2020-11-18 19:53:51 -08:00

Add port argument in the connection command

This commit is contained in:
Nicolas Viennot 2013-11-01 13:43:40 -04:00
parent 3df24cda34
commit 4bd26896f8
3 changed files with 12 additions and 7 deletions

View File

@ -100,6 +100,7 @@ static void tmate_header(struct tmate_decoder *decoder,
struct tmate_unpacker *uk)
{
char hostname[128];
char port_arg[16] = {0};
char *client_version = xstrdup("< 1.8.6");
decoder->protocol = unpack_int(uk);
@ -119,11 +120,14 @@ static void tmate_header(struct tmate_decoder *decoder,
if (gethostname(hostname, sizeof(hostname)) < 0)
tmate_fatal("cannot get hostname");
tmate_notify("Remote session read only: ssh ro-%s@%s.%s (clear your screen if you share this)",
tmate_session_token_ro, hostname, TMATE_DOMAIN);
if (tmate_port != 22)
sprintf(port_arg, " -p%d", tmate_port);
tmate_notify("Remote session: ssh %s@%s.%s",
tmate_session_token, hostname, TMATE_DOMAIN);
tmate_notify("Remote session read only: ssh%s ro-%s@%s.%s (clear your screen if you share this)",
port_arg, tmate_session_token_ro, hostname, TMATE_DOMAIN);
tmate_notify("Remote session: ssh%s %s@%s.%s",
port_arg, tmate_session_token, hostname, TMATE_DOMAIN);
}
extern u_int next_window_pane_id;

View File

@ -17,6 +17,7 @@
#include <fcntl.h>
#include "tmate.h"
int tmate_port = TMATE_DEFAULT_PORT;
struct tmate_encoder *tmate_encoder;
int tmux_socket_fd;
const char *tmate_session_token = "main";
@ -62,7 +63,6 @@ long tmate_get_random_long(void)
int main(int argc, char **argv, char **envp)
{
int opt;
int port = TMATE_DEFAULT_PORT;
const char *keys_dir = "keys";
#ifdef TMATE_RECORD_REPLAY
const char *replay_file = NULL;
@ -71,7 +71,7 @@ int main(int argc, char **argv, char **envp)
while ((opt = getopt(argc, argv, "p:l:vk:r:")) != -1) {
switch (opt) {
case 'p':
port = atoi(optarg);
tmate_port = atoi(optarg);
break;
case 'l':
log_path = optarg;
@ -117,7 +117,7 @@ int main(int argc, char **argv, char **envp)
(mkdir(TMATE_WORKDIR "/jail", 0700) < 0 && errno != EEXIST))
tmate_fatal("Cannot prepare session in " TMATE_WORKDIR);
tmate_ssh_server_main(keys_dir, port);
tmate_ssh_server_main(keys_dir, tmate_port);
return 0;
}

View File

@ -160,6 +160,7 @@ extern void tmate_ssh_server_main(const char *keys_dir, int port);
#define TMATE_WORKDIR "/tmp/tmate"
#define TMATE_JAIL_USER "nobody"
extern int tmate_port;
extern struct tmate_encoder *tmate_encoder;
extern int tmux_socket_fd;
extern const char *tmate_session_token;