Automate Remote SSH Control of Computers with Expect Scripts [Tutorial]

preview_player
Показать описание

How to Combine Expect & Bash Scripts

Cyber Weapons Lab, Episode 210

Bash scripts are the normal way to get into automation. However, they have their limitations. In this episode of Cyber Weapons Lab, we'll look at those limitations and learn about an alternative called expect scripts. Which, can be useful when we need to respond to variables, such as when you log in via SSH.

Follow Null Byte on:
Рекомендации по теме
Комментарии
Автор

This brings back memories. I used this exact method of ssh-ing and executing tasks on a system while supporting remote staff in Ukraine while me located out in LAX some years ago. Love the combo of Linux w/Expect scripting. Excellent creativity!

Good work!

rene_from_so_cal
Автор

OH MY GOD THIS CHANNEL HAS SO MUCH CONTENT! DUDE I WISH YT RECOMMENDED U EARLIER

apurvsharma
Автор

Thanks for using motionEyeOS on one of your PIs.

kevinshumaker
Автор

Excellent tutorial. Well explained. Thank you.

randomrat
Автор

I love your videos on coding very helpful and helped me out alot

usbwarror
Автор

Expect is pretty bomb. I learned about it when I wanted to auto login to SFTP from another location to do periodic backups. Flawless.

Dimrain
Автор

00:34 The man that doesn't blink, winks.

PixieSea
Автор

Awesome thanks for the info!! Great video and channel!!!

opc
Автор

lol was looking for scripting in general, but this video solves an issue with my broken rpi

axolum
Автор

Thank You Sir for video. 1:30 am here Kappa

zaczaemnowezycie
Автор

How does this compare by lets say using Ansible for automation. You could make a playbook for localhost and do the above without issues, plus you will have the benefit of all controls and plugins if you want to extend.

edgecrushr
Автор

could you make a video on pwndb and tools like it?

rolandchristensen
Автор

Thank you for this informations! Very useful.

I have a task: I need to ssh into multiple switches (about 200. All the switches have very well defined names in the DNS) and I need to check one thing from their configuration. How about doing that? I guess I will need a way to grab the IP addresses, therefore modifying the 'arp-scan-l' line and then use a for loop I guess, right?

In pseudocode it would be something like this.
- grab all the ip addresses in the domain whose names starts with "blablabla"
- foreach of these ip addresses spawn an ssh process ;
- run the command for showing the switch configuration file.
- eventually grab the config into a txt file or whatever.

raducumihaicristian
Автор

I am getting a (file "expect. exp" line 15) help please

eagleeyeviewimages
Автор

Would it be possible to combine such ssh tasks via expect script with a python script? Just like bash commands can be executed within a python script, so could the same be done with expect? Or should ssh tasks be rather done with python only?

Blentux
Автор

I don't understand the interest :
It looks like : you execute a script and you enter the password.
Always 2 things to write

lasourisRKO
Автор

why are we rebooting after the ssh connection in expect.exp script?

bbftrfq
Автор

I need help for calling a shell inside expect shell

PrasoonDeshmukh
Автор

i need to log onto a remote server via ssh and a key...
then i need to run a command to update the certificates of the servers website
then i need to restart a couple of services
then i need to log off
all this is to be run from a cron job
is this possible....im a bit worried about using automatic ssh key logon..as i cannot send an ssh password over the line..and i need zero user input.

runthomas
Автор

Example showing automation using SSH keys (so you don't have to login) and rexec command vs. expect? Expect is kinda wonky sometimes.

timlind