ssh target of link local ipv6 might have network interface
name prefixed by 'kdump-', which is not in known_hosts while
dumping, leading to failure in dump_ssh.
This commit
1) adds a helper function is_ipv6_link_local_ifname_prefixed
to find out whether a host is a link local ipv6 address
with 'kdump-' prefixed ifname;
2) makes dump_ssh cancel 'StrictHostKeyChecking' for link
local ipv6 address cases in order to bypass the known_hosts,
for it's not possible to add 'kdump-' variants in hashed
known_hosts if there is any need.
Signed-off-by: Ziyue Yang <ziyang(a)redhat.com>
---
dracut-kdump.sh | 10 +++++++++-
kdump-lib.sh | 8 ++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index b75c2a5..2c32e4e 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -71,10 +71,18 @@ dump_raw()
dump_ssh()
{
- local _opt="-i $1 -o BatchMode=yes -o StrictHostKeyChecking=yes"
+ local _opt="-i $1 -o BatchMode=yes"
local _dir="$KDUMP_PATH/$HOST_IP-$DATEDIR"
local _host=$2
+ # cancel HostKeyChecking for link-local ipv6 address
+ # with "kdump-" prefixed interface name
+ if is_ipv6_link_local_ifname_prefixed $(get_remote_host $_host); then
+ _opt+=" -o StrictHostKeyChecking=no"
+ else
+ _opt+=" -o StrictHostKeyChecking=yes"
+ fi
+
echo "kdump: saving to $_host:$_dir"
cat /var/lib/random-seed > /dev/urandom
diff --git a/kdump-lib.sh b/kdump-lib.sh
index fb3e354..06548fe 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -317,6 +317,14 @@ is_ipv6_link_local()
echo $1 | grep -q "^fe80::"
}
+is_ipv6_link_local_ifname_prefixed()
+{
+ is_ipv6_link_local $1 && {
+ local _postfix=${1##*\%}
+ echo $_postfix | grep -q "^kdump-"
+ }
+}
+
# get ip address or hostname from nfs/ssh config value
get_remote_host()
{
--
2.9.3