view sshfp_update.sh @ 0:d7fc9c3b4d87

Adding SSHFP CGI and update script
author Dominic Cleal <dominic-cleal@cdo2.com>
date Thu, 19 Nov 2009 11:54:21 +0000
parents
children 9b1165b3f241
line wrap: on
line source

#!/bin/sh
#
# Updates this host's SSH fingerprints to the sshfp.cgi server
#
# Copyright (c) 2009 CDO2 Limited
# Author: Dominic Cleal <dominic-cleal@cdo2.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

URL="https://admin.example.net/cgi-bin/sshfp.cgi"
RSA_KEY=/etc/ssh/ssh_host_rsa_key.pub
DSA_KEY=/etc/ssh/ssh_host_dsa_key.pub

test -f "$RSA_KEY" || exit 1
test -f "$DSA_KEY" || exit 1

RSA_FP=$(ssh-keygen -lf "$RSA_KEY" | awk '{ print $2 }')
DSA_FP=$(ssh-keygen -lf "$DSA_KEY" | awk '{ print $2 }')

exec curl "$URL?action=update&rsa=$RSA_FP&dsa=$DSA_FP"