import os from utils import load_users users = load_users('./users.txt') command = 'ssh-keygen -b 8192 -N "" -C "" -f {0}' for user in users: if not os.path.isfile(user): this_command = command.format(user) os.system(this_command)