Manage SSH connections with Python for Secure Remote Login

preview_player
Показать описание
🤓 Don't forget to subscribe to my Channel! 💻
------
In this video we are going to look at SSH and Python. SSH or Secure Shell is a network protocol that allows administrators to securely connect to a server over an unsecured network. SSH can use public key encryption for authentication and is a great real-world application for the public key encryption videos we did earlier.

This video will also help you understand how SSH works, even if you are not planning to use Python.

SSH is widely used for connecting to Linux or terminal based systems and Again, a lot of the connectivity with SSH can be done with terminal commands and bash scripting, but we are doing to do it with python, which will give us a little more flexibility. SSH is a powerful but with a few lines of python code, you’ll be able to script and automate all ssh has to offer.

So..some background on connectivity with SSH before we start coding…

So, basically how this works is …the client opens a connection to a remote host. The host negotiates the encryption and presents the client with its SSH public key to verify the authenticity of the host. The server then creates an encrypted tunnel with symmetric encryption and something call Diffie Helman.

The user then can authentic to the server with their username and password through this secure tunnel. We will write some python code to automate this step.

But a more secure and easier way to authenticate without passwords is with SSH keys. We modify our code to connect this way as well so you can connect to multiple servers with your python scripts.

For our environment here, I have remote hosts, which is a raspberry pi, and a client which is the terminal window on a mac. To enable ssh on the host or server, you typically type “systemctl enable ssh” and after that, assuming you have a username on the host/server, …we should be all set.



To install SSH, simply use pip3 install paramiko and…. You are all set!
Рекомендации по теме
Комментарии
Автор

really clean code. Love the additional info on generating SSH keys for W01 and Linux! That's really helpful

purplemonkeydishwasher
Автор

Thanks for this short but high signal video. After wandering the internet, looking at all kinds of this or that to simply open a tunnel, I landed here. Super super helpful and I very much appreciate you putting this together.

ricksegalCanada
Автор

Thank you for this, I will use this as a base for what I was trying to do with my Proxmox hypervisor.

itpugil
Автор

Great stuff as usual! It's always fun to learn more from these videos.

WorldDstroyer
Автор

Great examples Paul nice to hear you still working on the channel.

SanMan
Автор

Amazing video! Thank you for sharing your knowledge

creonte
Автор

Hey, Everything is so well explained, thank you so much!!!; but i have got an error saying: "failed to add the host to the list of known hosts windows", how do i resolve this?
Thanks in advance!!!!

rohithap
Автор

Can I able to run multiple commands with this code? I have a python file inside a jetson nano in desktop, so I need to make an application with tkinter to open that file from another system which has windows os through ssh.. Is it possible?

Rey_Psico
Автор

thanks so much, but I tried same thing with a command that runs a python script on my remote server, but the script is not running? is there anything else needed to run a python script on my remote server

fenylmecc
Автор

Once login, I'm switching to admin user using sudo su - user then it is asking for password. How to give that password from python paramiko?

sunilveerendravattikuti
Автор

How to save the result and send it to mail

shadow_self
Автор

interpreter '/usr/bin/python' doesn't exist on remote server help me @@

kenhgaming
Автор

How would you do this for multiple clients?

James-nooc
Автор

At 3.03 I'm lost. This is too fast for a tutorial.

automaticasa_matteosulis