def readsshconfig(self):
        config = os.path.expanduser("~/.ssh/config")
        if not os.path.exists(config):
            return
        f = open(config, "r")
        sshconfig = SSHConfig()
        sshconfig.parse(f)
        f.close()
        host = self.host
        try:
            host, port = host.split(":")
        except:
            port = None
        opt = sshconfig.lookup(host)

        if port is None:
            port = opt.get("port")

        host = opt.get("hostname", host)
        if port:
            host = "%s:%s" % (host, port)
        self.host = host
        if not self.identityfile:
            self.identityfile = opt.get("identityfile", None)
            if self.identityfile:
                self.identityfile = os.path.expanduser(self.identityfile).strip()
        if not self.user:
            self.user = opt.get("user", "root")
Beispiel #2
0
    def readsshconfig(self):
        config = os.path.expanduser('~/.ssh/config')
        if not os.path.exists(config):
            return
        f = open(config,'r')
        sshconfig = SSHConfig()
        sshconfig.parse(f)
        f.close()
        host = self.host
        try:
            host,port = host.split(':')
        except:
            port = None
        opt = sshconfig.lookup(host)

        if port is None:
            port = opt.get('port')

        host = opt.get('hostname', host)
        if port:
            host = "%s:%s" % (host,port)
        self.host=host
        if not self.identityfile:
            self.identityfile = opt.get('identityfile', None)
            if self.identityfile:
                self.identityfile = os.path.expanduser(self.identityfile).strip()
        if not self.user:
            self.user=opt.get('user','root')
    def readsshconfig(self):
        config = os.path.expanduser('~/.ssh/config')
        if not os.path.exists(config):
            return
        f = open(config,'r')
        sshconfig = SSHConfig()
        sshconfig.parse(f)
        f.close()
        opt = sshconfig.lookup(self.host)
        if opt:
            self.host = opt.get('hostname', self.host)
            self.port = opt.get('port', self.port)

        if not self.identityfile:
            self.identityfile = opt.get('identityfile', None)
            if self.identityfile:
                self.identityfile = os.path.expanduser(self.identityfile).strip()
        if not self.user:
            self.user=opt.get('user','root')