Do you ssh too often and to many different machines?

It’s been a long time, since I last wrote a post. And this is going to be a short one.
At my recent job, we have all these test environments (about 3500 of them) that have the same username and password.
I kind of got tired typing the username and password every time I had to login to a machine to test out something.

Well a keyless access would definitely have made things easier, but you can understand why you couldn’t have keyless access to 3500 environments, each running the risk of being phoenixed anytime.

I created a small expect script to get around the problem. Expect is a bash utility, that helps provide inputs in an automated way for scripts that expect user inputs. You may need to install it.

On a OsX machine, you can simply do brew install expect

https://gist.github.com/anjanashankar9/067b605633f7b80ff40463f22758751a#file-expect-bash

The interact on last line opens an interactive ssh shell.

Now, you can save this with a .exp extension, give an executable permission to it. Setup an alias, so that your newssh command lands to this, and you are all set.
This has made me save a couple of seconds on every login. And now I am wondering why did I wait for so many months before doing this 🙂

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s