DEV Community

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

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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay