DEV Community

Cover image for How to connect a Linux server via a Bash script.
Ikechukwu Kelechi Alexander
Ikechukwu Kelechi Alexander

Posted on

How to connect a Linux server via a Bash script.

System administrators and developers frequently connect to Linux servers via SSH (Secure Shell). This method can be automated using a Bash script, saving time and reducing repetitive effort. In this tutorial, we will download and execute a basic Bash script to connect to a Linux server.

Here are the steps to follow:

1. Download and install Git Bash
If you don't have Git Bash already installed on your system, then you can download the application by clicking https://git-scm.com/downloads

Git

2. Go to Azure Portal to complete the following tasks:

[i] search and open Virtual Machine on the search bar
VM

[ii] Create and Select the Azure VM
Create + Choose VM

[iii] Create new Resource Group, give the VM name on Region choose any one from the options.
Rg and Others

[iv] On the Image Select Ubuntu Server, on Authentication type select SSH public key

Rg and Others Contd

[v] Give a username on Select inbound ports thick: HTTP (80) and SSH (22) then Review + Create.
RG contd

[vi] Validation passed! then select Create
VP + Create

[vi] Download Private key and Create resource, then return to create VM
Download

[vii] Go to Resource
Go to Resource

[viii] Copy the ip address and open the ip
IP

[vix] Extend the Idle Timeout to 30, Save and exit
Idle timeout

[x] Open your Git Bash or Power Shell. I will launch our Git Bash and run the script by typing this command below to connect to our Linux Server but ensure the downloaded key is on Downloads Directory.

Git Bash

At last, we have successfully logged into our server.

I hope this helps! Thanks; see you later.

👋 While you are here

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay