forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[openssh] Introduce custom openssh-server package for supporting reve…
…rse console SSH (sonic-net#5717) * Build and install openssh from source * Copy openssh deb package to dest folder * Update make rule * Update sonic debian extension * Append empty line before EOF * Update openssh patch * Add openssh-server to base image dependency * Fix indent type * Fix comments * Use commit id instead of tag id and add comment Signed-off-by: Jing Kan [email protected]
- Loading branch information
1 parent
5815b06
commit 47b1da4
Showing
7 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
SPATH := $($(OPENSSH_SERVER)_SRC_PATH) | ||
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/openssh.mk rules/openssh.dep | ||
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) | ||
DEP_FILES += $(shell git ls-files $(SPATH)) | ||
|
||
$(OPENSSH_SERVER)_CACHE_MODE := GIT_CONTENT_SHA | ||
$(OPENSSH_SERVER)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) | ||
$(OPENSSH_SERVER)_DEP_FILES := $(DEP_FILES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# openssh package | ||
|
||
OPENSSH_VERSION = 7.9p1-10+deb10u2 | ||
|
||
export OPENSSH_VERSION | ||
|
||
OPENSSH_SERVER = openssh-server_$(OPENSSH_VERSION)_$(CONFIGURED_ARCH).deb | ||
$(OPENSSH_SERVER)_SRC_PATH = $(SRC_PATH)/openssh | ||
SONIC_MAKE_DEBS += $(OPENSSH_SERVER) | ||
|
||
# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} | ||
# are archived into debug one image to facilitate debugging. | ||
# | ||
DBG_SRC_ARCHIVE += openssh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.ONESHELL: | ||
SHELL = /bin/bash | ||
.SHELLFLAGS += -e | ||
|
||
MAIN_TARGET = openssh-server_$(OPENSSH_VERSION)_$(CONFIGURED_ARCH).deb | ||
DERIVED_TARGETS = openssh-server-dbgsym_$(OPENSSH_VERSION)_$(CONFIGURED_ARCH).deb | ||
|
||
$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : | ||
# Obtain openssh: https://salsa.debian.org/ssh-team/openssh/-/tree/debian/1%257.9p1-10+deb10u2 | ||
rm -rf ./openssh-server | ||
git clone https://salsa.debian.org/ssh-team/openssh.git openssh-server | ||
pushd ./openssh-server | ||
|
||
# Check out tag: debian/1%7.9p1-10+deb10u2 | ||
git checkout -b openssh-src -f 6d9ca74c48d9911342c6ca5aaac8a25974fa2619 | ||
|
||
# Apply patch series | ||
stg init | ||
stg import -s ../patch/series | ||
|
||
# Build package | ||
sudo apt-get -y build-dep openssh | ||
dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) | ||
popd | ||
|
||
mv $(DERIVED_TARGETS) $* $(DEST)/ | ||
|
||
$(addprefix $(DEST)/, $(DERIVED_TARGETS)): $(DEST)/% : $(DEST)/$(MAIN_TARGET) |
36 changes: 36 additions & 0 deletions
36
src/openssh/patch/0001-Put-style-as-line-number-to-ssh-session-environment-.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
From 6e8cca780dab4680292192058b90a4a28f35d4ab Mon Sep 17 00:00:00 2001 | ||
From: Blueve <[email protected]> | ||
Date: Mon, 26 Oct 2020 06:44:59 +0000 | ||
Subject: [PATCH 1/1] Put style as line number to ssh session environment | ||
variable | ||
|
||
By default, the content between : and @ will be trimmed by sshd before it do | ||
authentication and the trimmed string will be dropped silently. To use this | ||
segment as line number for reverse SSH feature, we need to modify the source | ||
code of OpenSSH and put this segment to a environment variable | ||
SSH_TARGET_CONSOLE_LINE, then we can insert a short script into /etc/bash.bashrc | ||
and run command consutil connect $SSH_TARGET_CONSOLE_LINE to enter the | ||
management session automatically after user login. | ||
--- | ||
session.c | 5 +++++ | ||
1 file changed, 5 insertions(+) | ||
|
||
diff --git a/session.c b/session.c | ||
index 19f38637e..654371447 100644 | ||
--- a/session.c | ||
+++ b/session.c | ||
@@ -1209,6 +1209,11 @@ do_setup_env(struct ssh *ssh, Session *s, const char *shell) | ||
child_set_env(&env, &envsize, "SSH_ORIGINAL_COMMAND", | ||
original_command); | ||
|
||
+ /* Take advantage of authentication style field */ | ||
+ if (s->authctxt->style) | ||
+ child_set_env(&env, &envsize, "SSH_TARGET_CONSOLE_LINE", | ||
+ s->authctxt->style); | ||
+ | ||
if (debug_flag) { | ||
/* dump the environment */ | ||
fprintf(stderr, "Environment:\n"); | ||
-- | ||
2.25.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0001-Put-style-as-line-number-to-ssh-session-environment-.patch |