File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -107,3 +107,22 @@ def poweroff():
107
107
from nagios import schedule_downtime
108
108
execute (schedule_downtime , env ['host_string' ])
109
109
run ("sudo poweroff" )
110
+
111
+ @task
112
+ @hosts ('puppetmaster-1.management' )
113
+ def host_key (hostname ):
114
+ """
115
+ Check the SSH host key of a machine. This task runs on the Puppetmaster because
116
+ it's the only machine that knows about all host keys.
117
+
118
+ Usage:
119
+ fab production vm.host_key:backend-1.backend
120
+ """
121
+ with hide ('running' , 'stdout' ):
122
+ ssh_key = run ("grep {0} /etc/ssh/ssh_known_hosts | head -1" .format (hostname ))
123
+
124
+ if ssh_key == '' :
125
+ print 'Machine {0} not found in ssh_known_hosts file' .format (hostname )
126
+ else :
127
+ with hide ('running' ):
128
+ run ("ssh-keygen -l -f /dev/stdin <<< '{0}'" .format (ssh_key ))
You can’t perform that action at this time.
0 commit comments