From b7bfa4cbe13a1f180007c7133b13cfd40b2d6afc Mon Sep 17 00:00:00 2001 From: lilyLuLiu Date: Tue, 29 Oct 2024 13:31:04 +0800 Subject: [PATCH] fix error when connect bastion without key --- lib/common/remote.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/common/remote.sh b/lib/common/remote.sh index 158724d..d0ee3f5 100755 --- a/lib/common/remote.sh +++ b/lib/common/remote.sh @@ -40,19 +40,19 @@ Host proxy_host StrictHostKeyChecking no HostName ${BASTION_HOST} User ${BASTION_HOST_USERNAME} - IdentityFile ${BASTION_HOST_KEY_PATH} + Host target_host HostName ${TARGET_HOST} User ${TARGET_HOST_USERNAME} - IdentityFile ${TARGET_HOST_KEY_PATH} ProxyJump proxy_host + EOF - if [[ -z ${TARGET_HOST_KEY_PATH+x} ]]; then - sed -i"" -e '9d' ssh_config + if [[ -n ${TARGET_HOST_KEY_PATH+x} ]]; then + sed -i"" -e "11 i\ IdentityFile $TARGET_HOST_KEY_PATH" ssh_config fi - if [[ -z ${BASTION_HOST_KEY_PATH+x} ]]; then - sed -i"" -e '4d' ssh_config + if [[ -n ${BASTION_HOST_KEY_PATH+x} ]]; then + sed -i"" -e "5 i\ IdentityFile ${BASTION_HOST_KEY_PATH}" ssh_config fi cat ssh_config }