You dont need a IF CONDITION. Because if authentication fails, script will anyway raise exception and will not execute rest of the statements
So you should just put the statements after ssh.connect
, as they will only be executed if the connection is successful.
If you still want to put IF CONDITION what you can do is
conn = ssh.connect(device, username=username, password=password, timeout=4)
if conn is None:
print "Successfully Authenticated"