SSH

From Server STB
Revision as of 01:57, 4 February 2024 by Admin (talk | contribs)
Jump to navigation Jump to search

SSH PORT 22

Linux

#!/bin/bash
# Fungsi untuk mengecek apakah SSH Server sudah diinstal
check_ssh_installed() {
   if ssh -V &> /dev/null; then
       echo "OpenSSH sudah diinstal."
   else
       echo "OpenSSH belum diinstal."
   fi
}
# Fungsi untuk memulai layanan SSH
start_ssh_service() {
   echo "Memulai layanan SSH..."
   net start sshd
}
# Fungsi untuk mengecek status layanan SSH
check_ssh_service_status() {
   status=$(Get-Service -Name sshd | Select-Object -ExpandProperty Status)
   echo "Status layanan SSH: $status"
} 
# Fungsi utama
main() {
   check_ssh_installed
   # Install OpenSSH jika belum diinstal
   if ! ssh -V &> /dev/null; then
       echo "Menginstal OpenSSH..."
       Add-WindowsCapability -Online -Name OpenSSH.Server
   fi
   start_ssh_service
   check_ssh_service_status
   echo "Instalasi dan konfigurasi OpenSSH selesai."
}
# Jalankan fungsi utama
main

Windows 11