-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_ssh.sh
31 lines (24 loc) · 934 Bytes
/
install_ssh.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# Check if curl is installed
if ! command -v curl &> /dev/null; then
echo "curl is not installed. Please install curl using the following command:"
echo "sudo apt-get update && sudo apt-get install -y curl"
echo "After installing curl, rerun this script to install the SSH server."
exit 1
fi
# Check if openssh-server is installed
if ! dpkg -l | grep -qw openssh-server; then
echo "SSH server is not installed. Installing..."
sudo apt-get update
sudo apt-get install -y openssh-server
else
echo "SSH server is already installed."
fi
# Ensure the SSH service is enabled to start on boot
sudo systemctl enable ssh
# Start the SSH service
sudo systemctl start ssh
# Display the status of the SSH service
echo "Checking the status of the SSH service..."
sudo systemctl status ssh --no-pager | head -n 10
echo "SSH server has been installed and started. It will now start on every boot."