Site icon The Ultimate Linux Newbie Guide

SSHPass: How to SSH into a server using a script with no password (non-interactively)

SSHPass

Ever asked yourself:

First, if you just want to log into one or two servers without having to enter a password all the time, the best way to do this is via SSH private keys. Our tutorial on how to do this is here. However, if you find yourself in a situation where you might have tens or hundreds of servers to log into then this might be the solution for you. In my case, I had a situation where I had a few hundred servers, which all had really weak root passwords. I wanted to change the passwords on each box with a nice long random password. I wanted to script this so I didn’t have to do it manually for every server. I used a simple bash script in the end, however a configuration management system such as Ansible is also a good option if you want a repeatable way to do things like this.

Using SSHPass, which is freely available for pretty much every Unix distribution is the tool you probably want, check out this handy tutorial from *nixCraft:

Login To SSH Server / Provide SSH Password Using A Shell Script

Exit mobile version