Evans Kiptoo
2 min readFeb 3, 2023

Goodbye to Boring Password Inputs When Logging into SSH

Are you tired of repeatedly entering passwords and usernames every time you log into an SSH server? Do you want to make the process more efficient and less boring?

One of the most common issues with logging into an SSH server is the need to enter passwords and usernames every time you want to connect.

Well, am here to save your time. 😁 Let’s automate this process!

The idea is to just write a script that will authenticate us automatically using terminal.

Thanks to sshpass.

First thing first is installing sspass

sudo apt-get update
sudo apt-get install sshpass

Next:

create a file named connect.sh

open the file with any editor and write or paste the following.

#!/bin/bash

sshpass -p <password> ssh <username>@<server_address>

Replace <password> with your password, <username> with your username, and <server_address> with the address of the SSH server you want to log into.

<eg: sshpass -p “d12347abcdxzy” ssh <0yeabcdyaa@0yeabcdyaa.trust36wa.alx-cod.online

#!/bin/bash

echo "Connecting to ssh userxyz@userxyz.cyztatozyz.alx-cod.online..."

sshpass -p "d12347abcdxzy" ssh 08c3e0cba18d@08c3e0cba18d.c683676a.alx-cod.online

connect.sh/connect.sh at this Gist · Alx SSH Shortcut (github.com)

Now save the file. connect.sh

We need to make the file executable, do this:

chmod +x <./path/to/connect.sh>

Check if it is executable by typing ls and check if file connect.sh is green in color.

Next, we create an alias connect that we will use it every time when we are connecting.

type alias connect="path/to/connect.sh"

Now type connect in the terminal and see what happens!

If all goes well, you should see something close to this:

Gif showing how the solution works.

Well, if it helped you, share with your friends, especially my fellow ALX students.😊

Happy automation guys.