Same user/pass on multiple systems ssh

I am a novice linux user but not "new"

I have 3 Ubuntu 20.04 lts laptops, as well as a 20.04 lts desktop that I maintain at home on a private network from my lil old asus 1000p running ubuntu mate 20.04.

On each piece I have my own account with like username/password with sudo privledges on each requiring the same pass.

this gets redundant in console with ssh user@#.#.#.#, then enter myuserpass and then using sudo command and then also entering sudopass to continue on.

What I would like to do is write a small shell script for each system that I could call from say .sshshorthostname that would first open a new terminal tab and then connect to the specific host via ssh myuser@ipaddress, login with my current userpass and "automagically" achieve sudo.

I have read some different things about expect and sshpass and am unsure of which way I should proceed.

Any tips, ideas or suggestion would be greatly appreciative.

Have you heard of ansible? you can install ansible on the main system, configure your hosts as laptopA, laptopB, laptopC, pass ssh credentials, and let ansible do updates/upgrades in just one swoop.

There is also an expect language (search linux expect) that allows you to automate ssh scripts.

1 Like

Thank you, ansible seems to be what I was looking for short of writing scripts.