[why] systemctl is not supported when use docker
[how] use the sshd command
Signed-off-by: Xiao Shenwei xiaoshenwei96@163.com --- daemon/sshd | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/daemon/sshd b/daemon/sshd index 41fa99adf..6bfda467e 100755 --- a/daemon/sshd +++ b/daemon/sshd @@ -6,19 +6,31 @@ # sshr_port_base
. $LKP_SRC/lib/http.sh +. $LKP_SRC/lib/env.sh
sshr_ip=$LKP_SERVER [ -n "$sshr_port" ] || sshr_port=5050 [ -n "$sshr_port_len" ] || sshr_port_len=2000 [ -n "$sshr_port_base" ] || sshr_port_base=50000
+generate_key_file() +{ + echo -e "y\n" | ssh-keygen -t rsa -b 2048 -N '' -f /etc/ssh/ssh_host_rsa_key +} + run_ssh() { [ -n "$my_ssh_pubkey" ] || return umask 0077 mkdir -p /root/.ssh echo "$my_ssh_pubkey" > /root/.ssh/authorized_keys - systemctl start sshd + if is_docker; then + generate_key_file + sshd_path=$(cmd_path sshd) + $sshd_path -q + else + systemctl start sshd + fi }
data_success()
On Mon, Dec 21, 2020 at 10:13:29AM +0800, Xiao Shenwei wrote:
[why] systemctl is not supported when use docker
[how] use the sshd command
Signed-off-by: Xiao Shenwei xiaoshenwei96@163.com
daemon/sshd | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/daemon/sshd b/daemon/sshd index 41fa99adf..6bfda467e 100755 --- a/daemon/sshd +++ b/daemon/sshd @@ -6,19 +6,31 @@ # sshr_port_base
. $LKP_SRC/lib/http.sh +. $LKP_SRC/lib/env.sh
Best practice is to use realpath.
SCRIPT_DIR=$(dirname $(realpath $0)) PROJECT_DIR=$(dirname $SCRIPT_DIR) $PROJECT_DIR/lib/http.sh $PROJECT_DIR/lib/env.sh
Thanks, Chenglong
sshr_ip=$LKP_SERVER [ -n "$sshr_port" ] || sshr_port=5050 [ -n "$sshr_port_len" ] || sshr_port_len=2000 [ -n "$sshr_port_base" ] || sshr_port_base=50000
+generate_key_file() +{
- echo -e "y\n" | ssh-keygen -t rsa -b 2048 -N '' -f /etc/ssh/ssh_host_rsa_key
+}
run_ssh() { [ -n "$my_ssh_pubkey" ] || return umask 0077 mkdir -p /root/.ssh echo "$my_ssh_pubkey" > /root/.ssh/authorized_keys
- systemctl start sshd
- if is_docker; then
generate_key_file
sshd_path=$(cmd_path sshd)
$sshd_path -q
- else
systemctl start sshd
- fi
}
data_success()
2.23.0
. $LKP_SRC/lib/http.sh +. $LKP_SRC/lib/env.sh
Best practice is to use realpath.
may be in the same repo, it's better use relative path. you donot need to care the realpath where ever it is.
SCRIPT_DIR=$(dirname $(realpath $0)) PROJECT_DIR=$(dirname $SCRIPT_DIR)
If you want to get the top dir for the repo, use: git rev-parse --show-toplevel
Thanks, Luan Shengde
$PROJECT_DIR/lib/http.sh $PROJECT_DIR/lib/env.sh
Thanks, Chenglong
sshr_ip=$LKP_SERVER [ -n "$sshr_port" ] || sshr_port=5050 [ -n "$sshr_port_len" ] || sshr_port_len=2000 [ -n "$sshr_port_base" ] || sshr_port_base=50000
+generate_key_file() +{
- echo -e "y\n" | ssh-keygen -t rsa -b 2048 -N '' -f /etc/ssh/ssh_host_rsa_key
+}
run_ssh() { [ -n "$my_ssh_pubkey" ] || return umask 0077 mkdir -p /root/.ssh echo "$my_ssh_pubkey" > /root/.ssh/authorized_keys
- systemctl start sshd
- if is_docker; then
generate_key_file
sshd_path=$(cmd_path sshd)
$sshd_path -q
- else
systemctl start sshd
- fi
}
data_success()
2.23.0
On Tue, Dec 22, 2020 at 09:24:06AM +0800, Luan Shengde wrote:
. $LKP_SRC/lib/http.sh +. $LKP_SRC/lib/env.sh
Best practice is to use realpath.
may be in the same repo, it's better use relative path. you donot need to care the realpath where ever it is.
ignore this section.
Thanks, Luan Shengde
SCRIPT_DIR=$(dirname $(realpath $0)) PROJECT_DIR=$(dirname $SCRIPT_DIR)
If you want to get the top dir for the repo, use: git rev-parse --show-toplevel
Thanks, Luan Shengde
$PROJECT_DIR/lib/http.sh $PROJECT_DIR/lib/env.sh
Thanks, Chenglong
sshr_ip=$LKP_SERVER [ -n "$sshr_port" ] || sshr_port=5050 [ -n "$sshr_port_len" ] || sshr_port_len=2000 [ -n "$sshr_port_base" ] || sshr_port_base=50000
+generate_key_file() +{
- echo -e "y\n" | ssh-keygen -t rsa -b 2048 -N '' -f /etc/ssh/ssh_host_rsa_key
+}
run_ssh() { [ -n "$my_ssh_pubkey" ] || return umask 0077 mkdir -p /root/.ssh echo "$my_ssh_pubkey" > /root/.ssh/authorized_keys
- systemctl start sshd
- if is_docker; then
generate_key_file
sshd_path=$(cmd_path sshd)
$sshd_path -q
- else
systemctl start sshd
- fi
}
data_success()
2.23.0
On Tue, Dec 22, 2020 at 09:24:06AM +0800, Luan Shengde wrote:
. $LKP_SRC/lib/http.sh +. $LKP_SRC/lib/env.sh
Best practice is to use realpath.
may be in the same repo, it's better use relative path. you donot need to care the realpath where ever it is.
SCRIPT_DIR=$(dirname $(realpath $0)) PROJECT_DIR=$(dirname $SCRIPT_DIR)
If you want to get the top dir for the repo, use: git rev-parse --show-toplevel
git is much more heavy weight than realpath, and relies on git repo. What if we don't have .git dir (eg. when packaged in RPM in future)?
Thanks, Fengguang
$PROJECT_DIR/lib/http.sh $PROJECT_DIR/lib/env.sh
Thanks, Chenglong
sshr_ip=$LKP_SERVER [ -n "$sshr_port" ] || sshr_port=5050 [ -n "$sshr_port_len" ] || sshr_port_len=2000 [ -n "$sshr_port_base" ] || sshr_port_base=50000
+generate_key_file() +{
- echo -e "y\n" | ssh-keygen -t rsa -b 2048 -N '' -f /etc/ssh/ssh_host_rsa_key
+}
run_ssh() { [ -n "$my_ssh_pubkey" ] || return umask 0077 mkdir -p /root/.ssh echo "$my_ssh_pubkey" > /root/.ssh/authorized_keys
- systemctl start sshd
- if is_docker; then
generate_key_file
sshd_path=$(cmd_path sshd)
$sshd_path -q
- else
systemctl start sshd
- fi
}
data_success()
2.23.0
On Tue, Dec 22, 2020 at 09:29:36AM +0800, Wu Fengguang wrote:
On Tue, Dec 22, 2020 at 09:24:06AM +0800, Luan Shengde wrote:
. $LKP_SRC/lib/http.sh +. $LKP_SRC/lib/env.sh
Best practice is to use realpath.
may be in the same repo, it's better use relative path. you donot need to care the realpath where ever it is.
SCRIPT_DIR=$(dirname $(realpath $0)) PROJECT_DIR=$(dirname $SCRIPT_DIR)
If you want to get the top dir for the repo, use: git rev-parse --show-toplevel
git is much more heavy weight than realpath, and relies on git repo. What if we don't have .git dir (eg. when packaged in RPM in future)?
I got it
Thanks, Luan Shengde
Thanks, Fengguang
$PROJECT_DIR/lib/http.sh $PROJECT_DIR/lib/env.sh
Thanks, Chenglong
sshr_ip=$LKP_SERVER [ -n "$sshr_port" ] || sshr_port=5050 [ -n "$sshr_port_len" ] || sshr_port_len=2000 [ -n "$sshr_port_base" ] || sshr_port_base=50000
+generate_key_file() +{
- echo -e "y\n" | ssh-keygen -t rsa -b 2048 -N '' -f /etc/ssh/ssh_host_rsa_key
+}
run_ssh() { [ -n "$my_ssh_pubkey" ] || return umask 0077 mkdir -p /root/.ssh echo "$my_ssh_pubkey" > /root/.ssh/authorized_keys
- systemctl start sshd
- if is_docker; then
generate_key_file
sshd_path=$(cmd_path sshd)
$sshd_path -q
- else
systemctl start sshd
- fi
}
data_success()
2.23.0