Search notes:

Python standard library: netrc

netrc reads and parses files adhering to the netrc format (like ~/.netrc)
import netrc
import os
import paramiko

server_name='milky.way'

netrc_file = os.path.join(os.path.expanduser('~'), '.netrc')
authenticators = netrc.netrc(netrc_file).authenticators(server_name)

if authenticators:
    username, _, password = authenticators

    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

    ssh.connect(server_name, port=2121, username=username, password=password)

  # do stuff

    ssh.close()
else:
    print(f'Credentials for {server_name} not found in {netrc_file}')

See also

standard library

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758198567, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/standard-library/netrc(60): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78