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

February 20, 2021 by 26 Comments

Our Premium Ethical Hacking Bundle Is 90% Off:

How to Combine Expect & Bash Scripts
Full Tutorial:
Subscribe to Null Byte:
Kody’s Twitter:

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.

To learn more, check out the article on Null Byte’s site:

Automate tasks with Bash scripts:
Automate recon with Bash scripts:

Follow Null Byte on:


26 Replies to “Automate Remote SSH Control of Computers with Expect Scripts [Tutorial]”

  1. 06_8B says:

    lets go another upload

  2. entourage says:

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

  3. Zipf says:

    Yeeeees! The video I was looking for

  4. I was here 1 minutes after the video post

  5. BrumMen says:

    yay li just needed this lmao

  6. the the says:

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

  7. lol wtf expect "assword:" ???

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

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

  10. max idk says:

    I love this. Thank you

  11. Answer to this comment with your customized script!

  12. Med Smidi says:

    or using python with the library Pexpect and you can use sys or subprocess and paramiko for the ssh

  13. You Blinked!!! Thanks for another great tip

  14. Cyber Rock says:

    #! bin/bash

    echo "Kody is the goat"

  15. æ says:

    I love automation! great video❤️

  16. GeeK Batman says:

    ssh -t username@host 'reboot' works fine for me.

  17. Kaity Codes says:

    Bash | 🙅🏽‍♀️
    Expect | 🤦🏽‍♀️

    Bash + Expect | 😌😏😎

  18. Dimrain13 says:

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

  19. Nice video bro 👍👍