@decorators.which('ssh-keyscan')
def recv_known_host(hostname, enc=None, port=None, hash_known_hosts=True, timeout=5):
 need_dash_t = ('CentOS-5',)
 cmd = ['ssh-keyscan']
 if port:
  cmd.extend(['-p', port])
 if enc:
  cmd.extend(['-t', enc])
 if ((not enc) and (__grains__.get('osfinger') in need_dash_t)):
  cmd.extend(['-t', 'rsa'])
 if hash_known_hosts:
  cmd.append('-H')
 cmd.extend(['-T', str(timeout)])
 cmd.append(hostname)
 lines = None
 attempts = 5
 while ((not lines) and (attempts > 0)):
  attempts = (attempts - 1)
  lines = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
 known_hosts = list(_parse_openssh_output(lines))
 return (known_hosts[0] if known_hosts else None)

@ decorators . which ( 'ssh-keyscan' ) def recv_known_host ( hostname , enc = None , port = None , hash_known_hosts = True , timeout = 5 ) : need_dash_t = ( 'CentOS-5' , ) cmd = [ 'ssh-keyscan' ] if port : cmd . extend ( [ '-p' , port ] ) if enc : cmd . extend ( [ '-t' , enc ] ) if ( ( not enc ) and ( __grains__ . get ( 'osfinger' ) in need_dash_t ) ) : cmd . extend ( [ '-t' , 'rsa' ] ) if hash_known_hosts : cmd . append ( '-H' ) cmd . extend ( [ '-T' , str ( timeout ) ] ) cmd . append ( hostname ) lines = None attempts = 5 while ( ( not lines ) and ( attempts > 0 ) ) : attempts = ( attempts - 1 ) lines = __salt__ [ 'cmd.run' ] ( cmd , python_shell = False ) . splitlines ( ) known_hosts = list ( _parse_openssh_output ( lines ) ) return ( known_hosts [ 0 ] if known_hosts else None )
retrieve information about host public key from remote server hostname the name of the remote host enc defines what type of key is being used .