add new module sshd-dns which can process sshd conf files substituing IPs for hostnames
parent
b2efa57439
commit
7f15b61f23
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
sshd_dns () {
|
||||||
|
local dir
|
||||||
|
local dnsconf
|
||||||
|
local conf
|
||||||
|
dir=${1:-"/etc/ssh/sshd_config.d"}
|
||||||
|
pushd "$dir" 1>/dev/null || return;
|
||||||
|
for dnsconf in *.conf.dns; do
|
||||||
|
[[ -f "$dnsconf" ]] || break
|
||||||
|
conf=$(basename $dnsconf .dns)
|
||||||
|
echo "----- processing sshd file $dnsconf to $conf ----"
|
||||||
|
sudo cp $dnsconf $conf
|
||||||
|
cat $conf
|
||||||
|
echo -e "\n------------"
|
||||||
|
for host in $(sed -e 's/[ ,]/\n/g' $conf | sed -n 's/[Dd][Nn][Ss]://p'); do
|
||||||
|
echo found host $host, substituting $(dig +short $host)
|
||||||
|
sudo sed -i 's/[Dd][Nn][Ss]:'$host'/'$(dig +short $host)'/g' $conf
|
||||||
|
done
|
||||||
|
echo "----- created sshd conf file $conf ----"
|
||||||
|
cat $conf
|
||||||
|
echo -e "\n------------"
|
||||||
|
done
|
||||||
|
echo restart ssh service daemon to enable these changes
|
||||||
|
popd 1>/dev/null || return
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue