Print error msg when forget to specify user for ssh target

Resolves: https://issues.redhat.com/browse/FC-1046

We require that <user> be explicitly specified in 'ssh <user>@<hostname>'. When
forgetting to specify, such as 'ssh 192.168.10.2', a useful error log should be
printed instead of exiting directly.

Signed-off-by: Lichen Liu <lichliu@redhat.com>
Reviewed-by: Philipp Rudo <prudo@redhat.com>
This commit is contained in:
Lichen Liu 2024-01-05 14:40:12 +08:00 committed by Coiby Xu
parent 753e5060d7
commit 6943de2cdc

View File

@ -748,7 +748,12 @@ check_ssh_config()
[[ "${OPT[_fstype]}" == ssh ]] || return 0
target=$(ssh -G "${OPT[_target]}" | sed -n -e "s/^hostname[[:space:]]\+\([^[:space:]]*\).*$/\1/p")
[[ ${OPT[_target]} =~ .*@.* ]] || return 1
if [[ ${OPT[_target]} != *@* ]]; then
derror "Please verify that $KDUMP_CONFIG_FILE contains 'ssh <user>@<host>' and that it is properly formatted."
return 1
fi
if [[ ${OPT[_target]#*@} != "$target" ]]; then
derror "Invalid ssh destination ${OPT[_target]} provided."
return 1