Skip to Content
Mastering Python for Networking and Security
book

Mastering Python for Networking and Security

by José Manuel Ortega
September 2018
Intermediate to advanced
426 pages
10h 46m
English
Packt Publishing
Content preview from Mastering Python for Networking and Security

Establishing SSH connection with Paramiko

We can use the Paramiko module to create an SSH client and then connect it to the SSH server. This module will supply the SSHClient() class, which provides an interface to initiate server connections in a secure way. These instructions will create a new SSHClient instance, and connect to the SSH server by calling the connect() method:

import paramikossh_client = paramiko.SSHClient()ssh_client.connect(‘host’,username='username', password='password')

By default, the SSHClient instance of this client class will refuse to connect a host that does not have a key saved in our known_hosts file. With the AutoAddPolicy() class, you can set up a policy for accepting unknown host keys. Now, you need to run the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Python for Networking and Security - Second Edition

Mastering Python for Networking and Security - Second Edition

José Manuel Ortega
Python for Cybersecurity

Python for Cybersecurity

Howard E. Poston, III

Publisher Resources

ISBN: 9781788992510Supplemental Content