Create a gist now

Instantly share code, notes, and snippets.

Embed - file needed by
import os,subprocess,plumbum
import servers.secret as secret
sshDir = "%s/.ssh" % os.environ['HOME']
def create_ssh_dir():
if not os.path.exists(sshDir):
def install_pip2(ssh):
ssh : a plumdum machine <SshMachine ssh://root@>
return ssh["pip2"]("--version")
except plumbum.CommandNotFound:
return ssh["pip2"]("--version")
def add_to_known_host(hostName):
ipScanStr = "ssh-keyscan -H {hostName} >> {sshDir}/known_hosts"
nameScanStr = "ssh-keyscan {hostName} >> {sshDir}/known_hosts" = hostName,sshDir = sshDir),shell=True) = hostName,sshDir = sshDir),shell=True)
def write_base_ssh_config():
with open(os.path.join(sshDir,"id_rsa"),"wt") as f:
f.write(secret.idRsa)"sudo chmod 600 %s" % os.path.join(sshDir,"id_rsa"),shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment