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.

Top comments (0)