Package paramiko :: Module util
[frames] | no frames]

Module util

source code

Useful functions used by the rest of paramiko.

Classes
  PFilter
  Counter
Stateful counter for CTR mode crypto
Functions
 
inflate_long(s, always_positive=False)
turns a normalized byte string into a long-int (adapted from Crypto.Util.number)
source code
 
deflate_long(n, add_sign_padding=True)
turns a long-int into a normalized byte string (adapted from Crypto.Util.number)
source code
 
format_binary(data, prefix='') source code
 
format_binary_line(data) source code
 
hexify(s) source code
 
unhexify(s) source code
 
safe_string(s) source code
 
bit_length(n) source code
 
tb_strings() source code
 
generate_key_bytes(hash_alg, salt, key, nbytes)
Given a password, passphrase, or other human-source key, scramble it through a secure hash into some keyworthy bytes.
source code
 
load_host_keys(filename)
Read a file of known SSH host keys, in the format used by openssh, and return a compound dict of ``hostname -> keytype ->`` `PKey <paramiko.pkey.PKey>`.
source code
 
parse_ssh_config(file_obj)
Provided only as a backward-compatible wrapper around `.SSHConfig`.
source code
 
lookup_ssh_host_config(hostname, config)
Provided only as a backward-compatible wrapper around `.SSHConfig`.
source code
 
mod_inverse(x, m) source code
 
get_thread_id() source code
 
log_to_file(filename, level=10)
send paramiko logs to a logfile, if they're not already going somewhere
source code
 
get_logger(name) source code
 
retry_on_signal(function)
Retries function until it doesn't raise an EINTR error
source code
 
constant_time_bytes_eq(a, b) source code
Variables
  deflate_zero = '\x00'
  deflate_ff = '\xff'
  __package__ = 'paramiko'
Function Details

generate_key_bytes(hash_alg, salt, key, nbytes)

source code 

Given a password, passphrase, or other human-source key, scramble it
through a secure hash into some keyworthy bytes.  This specific algorithm
is used for encrypting/decrypting private key files.

:param function hash_alg: A function which creates a new hash object, such
    as ``hashlib.sha256``.
:param salt: data to salt the hash with.
:type salt: byte string
:param str key: human-entered password or passphrase.
:param int nbytes: number of bytes to generate.
:return: Key data `str`

load_host_keys(filename)

source code 

Read a file of known SSH host keys, in the format used by openssh, and
return a compound dict of ``hostname -> keytype ->`` `PKey
<paramiko.pkey.PKey>`. The hostname may be an IP address or DNS name.  The
keytype will be either ``"ssh-rsa"`` or ``"ssh-dss"``.

This type of file unfortunately doesn't exist on Windows, but on posix,
it will usually be stored in ``os.path.expanduser("~/.ssh/known_hosts")``.

Since 1.5.3, this is just a wrapper around `.HostKeys`.

:param str filename: name of the file to read host keys from
:return:
    nested dict of `.PKey` objects, indexed by hostname and then keytype