- How do we connect to an FTP server using the ftplib module through the connect() and login() methods?
ftp = FTP()
ftp.connect(host, 21)
ftp.login(‘user’, ‘password’)
- What method of the ftplib module allows it to list the files of an FTP server?
FTP.dir()
- Which method of the Paramiko module allows us to connect to an SSH server and with what parameters (host, username, password)?
ssh = paramiko.SSHClient()
ssh.connect(host, username=’username’, password=’password’)
- Which method of the Paramiko module allows us to open a session to be able to execute commands subsequently?
ssh_session = client.get_transport().open_session()
- How do we log in to an SSH server with an RSA certificate from which we've found out the route and password?
rsa_key= RSAKey.from_private_key_file('path_key_rsa',password)
client.connect('host',username='',pkey= rsa_key,password='')
- Which main class of the PySNMP module allows queries on SNMP agents?
CommandGenerator. Here's an example of its use:
from pysnmp.entity.rfc3413.oneliner import cmdgen
cmdGen = cmdgen.CommandGenerator()
- What is the instruction for informing Paramiko to accept server keys for the first time without interrupting the session or prompting the user?
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- Which way of connecting to an SSH server through the Transport() method provides another type of object to authenticate against the server?
transport = paramiko.Transport(ip_address)
transport.start_client()
- What is the Python FTP module, based in Paramiko, that provides a connection with FTP servers in a secure way?
pysftp, which is based on paramiko.
- Which method from ftplib do we need to use to download files, and which ftp command do we need to execute?
file_handler = open(DOWNLOAD_FILE_NAME, 'wb')
ftp_cmd = 'RETR %s' %DOWNLOAD_FILE_NAME
ftp_client.retrbinary(ftp_cmd,file_handler.write)