~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

  • Committer: Robert Collins
  • Date: 2005-11-03 16:08:17 UTC
  • mfrom: (1185.16.146)
  • Revision ID: robertc@robertcollins.net-20051103160817-ce8f8dbaafab2a22
MergeĀ fromĀ Martin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
    Transport implementation for SFTP access.
88
88
    """
89
89
 
90
 
    _url_matcher = re.compile(r'^sftp://(.*@)?(.*?)(:\d+)?(/.*)?$')
 
90
    _url_matcher = re.compile(r'^sftp://([^:@]*(:[^@]*)?@)?(.*?)(:\d+)?(/.*)?$')
91
91
    
92
92
    def __init__(self, base, clone_from=None):
93
93
        assert base.startswith('sftp://')
364
364
        m = self._url_matcher.match(url)
365
365
        if m is None:
366
366
            raise SFTPTransportError('Unable to parse SFTP URL %r' % (url,))
367
 
        self._username, self._host, self._port, self._path = m.groups()
 
367
        self._username, self._password, self._host, self._port, self._path = m.groups()
368
368
        if self._username is None:
369
369
            self._username = getpass.getuser()
370
370
        else:
371
371
            self._username = self._username[:-1]
 
372
        if self._password:
 
373
            self._password = self._password[1:]
 
374
            self._username = self._username[len(self._password)+1:]
372
375
        if self._port is None:
373
376
            self._port = 22
374
377
        else:
435
438
        if self._try_pkey_auth(transport, paramiko.DSSKey, 'id_dsa'):
436
439
            return
437
440
 
 
441
        if self._password:
 
442
            try:
 
443
                transport.auth_password(self._username, self._password)
 
444
                return
 
445
            except paramiko.SSHException, e:
 
446
                pass
 
447
 
438
448
        # give up and ask for a password
439
449
        password = getpass.getpass('SSH %s@%s password: ' % (self._username, self._host))
440
450
        try: