[paramiko] paramiko handling UTF-8

Robey Pointer robey at lag.net
Sun Jan 20 13:41:10 PST 2008


On 12 Jan 2008, at 7:17, David Guerizec wrote:

> Hello,
>
> Does anybody know what's the reason why paramiko is converting  
> passwords to
> UTF-8 before sending them on the network ?
>
> I have seen that sometimes this is not what servers want, since  
> passwords can
> be in any charsets.

It looks like this is part of the SSH standard. RFC 4252 says, on page  
10:

    Note that the ’plaintext password’ value is encoded in ISO-10646
    UTF-8.  It is up to the server how to interpret the password and
    validate it against the password database.  However, if the client
    reads the password in some other encoding (e.g., ISO 8859-1 - ISO
    Latin1), it MUST convert the password to ISO-10646 UTF-8 before
    transmitting, and the server MUST convert the password to the
    encoding used on that system for passwords.

So it looks like at least I didn't make it up. :)

If some servers are expecting a different encoding, we could make  
auth_handler only do UTF-8 encoding on unicode strings. So if you  
passed in a string pre-encoded into a str (=bytes), it wouldn't change  
the encoding. Would that work?

robey





More information about the paramiko mailing list