TAGS :Viewed: 15 - Published at: a few seconds ago

[ Use fabric to test only authentication ]

I have so many servers but the ldap system looks not reliable so I want to test if I can login to servers. I'm trying to use fabric to do this job like this:

env.user = username
env.host_string = host
print 'Testing %s ...' % host
with settings(hide('warnings', 'running', 'stdout', 'stderr'), warn_only = True, abort_on_prompts = True):
    dir = run('pwd')
    if dir:
        print dir

Is there any approach to just test the authentication without 'run'?

Answer 1


You could just use a for loop in bash?

for CHECK_HOST in $(xargs < newline_delimited_host_strings)
do
    ssh $CHECK_HOST exit || echo "$CHECK_HOST failed" && echo "$CHECK_HOST worked"
done