Create an Interactive SSH Shell using the Paramiko Library
Learn more from the full course
Python Network Programming | Network Apps & Hacking Tools
Learn How To Create Python 3 Networking Tools and Progress to Creating Your Own Python 3 Network Hacking Tools
05:42:11 of on-demand video • Updated April 2019
5.5 hours of Full HD video material comprised of 25 lectures.
Become familiar with basics of networking: internet architecture, IP addresses, Python TCP connections, Ports and Sockets
Discover core concepts of network communication and python networking
Learn how to use Python 3 TCP sockets to create client and server network applications.
Create over 15 different Python 3 networking applications for hackers.
Build a Python 3 IRC Bot and learn how to process IRC server responses using TCP sockets.
Create a Python 3 banner grabbing tool using TCP sockets to connect to remote services and log banner messages.
Code your own Web Server enumerator tool to scan web servers to find hidden directories or files using the requests library.
Create a Client/Server tool for transferring files to and from remote systems using TCP sockets.
Learn how to build a Stealth Port Scanner to scan remote servers using scapy without making a complete connection to the server.
Use the Paramiko library to make an interactive SSH Shell connection to a remote SSH server using Python 3.
Build your own SMTP Username Enumerator to find user accounts on remote systems using TCP sockets.
Develop a Python 3 sFTP tool to securely download and upload files to and from remote servers in Python 3.
Learn how to connect to a remote POP Mail Server and retrieve email from a remote server.
Create a Man-in-The-Middle Python 3 tool to sniff internet traffic from a remote system.
Code your own Host Discovery tool in Python 3 using scapy to locate live systems on a network using ARP, ICMP, and TCP methods.
Build a Data Scraping tool to harvest information from remote websites to locate IP Addresses, Email Addresses, and Phone Numbers of your target.
English [Auto]
In this video we're going to create a SSA client script in python. Now before we do that we want to go ahead and enable RSS H server. And if you're running Kelly Linux or Most Linux distributions you'll have an SSA show ever present stall and you simply need to start it up. And we're also going to need to install the pyramid pair Emiko python library. Let's go ahead and get that stalled all right. Perfect. All right. So let's go ahead and open up our code editor and create a new file. We'll call it SSA H clients. All right so the first thing we want to do is import param eco. We need to define our hostname. The port of the SSA server which will be 20 to the user name and the password all right now let's go ahead and create a try except block just to catch any generic errors. All right the first thing we want to do is create a client object from the apparent Mico library. So we create a client variable and create our client object. Next we want to load the system host keys from our system. And next we want to set a policy for any missing keys when we're connecting to a remote server and we'll set that to the auto add policy. This way if we connect to a server and we're missing the host keys it will automatically add them. All right. Now with that all way. Now we can actually connect to the remote SSA server so we'll do that using the Connect method pass and the hostname port the user name and the password. All right. In this instance we're going to create an interactive shell so we'll connect to the server will hold that connection and we'll create a prompt so we can type in commands and then get the output from the SSA server. So let's create an infinite loop and inside there let's create another try except block and when the user presses control see Let's go ahead and exit the loop. All right. Now let's get some input from the user. We'll do that using the input function and we'll create a prompt. Now we want an exit function. So if we type the exit command we'll go ahead and exit our while loop. All right. Now we need to exit a command on the remote SSA server. So we're going to need some variables and then we'll use client and the exact command function when we execute this function by passing in our command. It will then place the standard input output and error from the remote server into the appropriate variables. Now at this point all we need to do is simply display that to the screen. So we'll take the standard output use the read function to read the results and then decode that byte array into a string so we can display it to the screen. Finally the last thing we need to do is simply close our connection when we are complete change that variable. All right. So let's let's go over this again. So we're create our param Mico client object store that into the client variable will load our local system host keys then we'll set the missing host key policy to automatically add any host names and host keys to our system from there will connect to the remote server with our hostname port user name and password and then what we're gonna do is we're going to enter into a infinite loop and in that loop we're going to ask for input if the user types the exit command we'll go ahead and exit the while loop which will then execute the following line of code and exit from the remote server. Otherwise we're going to execute that command on the remote server which will then place the output into the standard input output and error and then we'll display that to the screen. Now if you wanted to make a more robust client you would probably also want to display the error so you can see any sort of error messages that any programs display. All right now let's go ahead and test out this code. So I typed Python 3 as this age client. And here we are with a prompt and as you can see we're able to execute multiple commands on the server. Now if we type exit again you can see it exits from the server. Let's connect back. And in this instance I'm going to press control see and again you see that we were able to exit from the server. So in this instance we created a very simple SSA client in python. Now there may be instances where you don't want to create an interactive show. You just want to connect to a remote SSA server. It may be read like a configuration file from some sort of application or maybe a device read that output and then return something back to you in which case you can simply use this client exact command and you don't have to do it inside this while loop or this using this input statement you could just execute your commands get the output process them and then the either display them to the screen or maybe write them to a log file of some sort. So that's going to conclude this. A basic SSA client in Python.