|
| 1 | +From 6e8cca780dab4680292192058b90a4a28f35d4ab Mon Sep 17 00:00:00 2001 |
| 2 | +From: Blueve <blueve@users.noreply.github.com> |
| 3 | +Date: Mon, 26 Oct 2020 06:44:59 +0000 |
| 4 | +Subject: [PATCH 1/1] Put style as line number to ssh session environment |
| 5 | + variable |
| 6 | + |
| 7 | +By default, the content between : and @ will be trimmed by sshd before it do |
| 8 | +authentication and the trimmed string will be dropped silently. To use this |
| 9 | +segment as line number for reverse SSH feature, we need to modify the source |
| 10 | +code of OpenSSH and put this segment to a environment variable |
| 11 | +SSH_TARGET_CONSOLE_LINE, then we can insert a short script into /etc/bash.bashrc |
| 12 | +and run command consutil connect $SSH_TARGET_CONSOLE_LINE to enter the |
| 13 | +management session automatically after user login. |
| 14 | +--- |
| 15 | + session.c | 5 +++++ |
| 16 | + 1 file changed, 5 insertions(+) |
| 17 | + |
| 18 | +diff --git a/session.c b/session.c |
| 19 | +index 19f38637e..654371447 100644 |
| 20 | +--- a/session.c |
| 21 | ++++ b/session.c |
| 22 | +@@ -1209,6 +1209,11 @@ do_setup_env(struct ssh *ssh, Session *s, const char *shell) |
| 23 | + child_set_env(&env, &envsize, "SSH_ORIGINAL_COMMAND", |
| 24 | + original_command); |
| 25 | + |
| 26 | ++ /* Take advantage of authentication style field */ |
| 27 | ++ if (s->authctxt->style) |
| 28 | ++ child_set_env(&env, &envsize, "SSH_TARGET_CONSOLE_LINE", |
| 29 | ++ s->authctxt->style); |
| 30 | ++ |
| 31 | + if (debug_flag) { |
| 32 | + /* dump the environment */ |
| 33 | + fprintf(stderr, "Environment:\n"); |
| 34 | +-- |
| 35 | +2.25.1 |
| 36 | + |
0 commit comments