<s> from Crypto . PublicKey import RSA <EOL> from django . core . files . base import ContentFile <EOL> from fabric_bolt . hosts import models <EOL> def create_ssh_config ( remote_user = '<STR_LIT:root>' , name = '<STR_LIT>' , <EOL> file_name = '<STR_LIT>' , email = '<STR_LIT>' , public_key_text = None , <EOL> private_key_text = None ) : <EOL> """<STR_LIT>""" <EOL> if not private_key_text and not public_key_text : <EOL> key = RSA . generate ( <NUM_LIT> ) <EOL> pubkey = key . publickey ( ) <EOL> private_key_text = key . exportKey ( '<STR_LIT>' ) <EOL> public_key_text = pubkey . exportKey ( '<STR_LIT>' ) <EOL> ssh_config = models . SSHConfig ( ) <EOL> ssh_config . name = name <EOL> ssh_config . private_key_file . save ( file_name , ContentFile ( private_key_text ) ) <EOL> ssh_config . public_key = '<STR_LIT>' . format ( public_key_text , email ) <EOL> ssh_config . remote_user = remote_user <EOL> ssh_config . save ( ) <EOL> return ssh_config </s>
