Enable SSH in Ubuntu 18
If you need to install OpenSSH on an offline Ubuntu machine without using sudo apt install, you can follow these steps to manually download the necessary packages on another machine (with internet access) and transfer them to the offline machine.
Steps to Install OpenSSH Offline
Step 1: Download the Required Packages on an Online Machine
Check your Ubuntu version:
- Run the following command on the offline machine to know the version of Ubuntu you are running (this is important to download compatible packages):bash
lsb_release -a
- Run the following command on the offline machine to know the version of Ubuntu you are running (this is important to download compatible packages):
Download the required packages:
- On a machine with internet access, go to the official Ubuntu Packages website.
- Search for the
openssh-serverpackage and note the dependencies for the version that matches your Ubuntu version.
Download the required
.debpackages:- On the online machine, download the necessary
.debfiles foropenssh-serverand its dependencies. You can either manually download them from the Ubuntu Packages website or useapton an online machine to download the packages:
bashsudo apt update sudo apt download openssh-serverThis command will download the
openssh-serverpackage and save the.debfile in the current directory. However, the dependencies also need to be downloaded separately. Use the following command to download all the dependencies at once:bashsudo apt-get download openssh-serverThis will download the
.debfiles foropenssh-serverand all its dependencies to the current directory.- On the online machine, download the necessary
Transfer the downloaded
.debfiles:- Use a USB drive or other methods to transfer the
.debfiles from the online machine to the offline machine.
- Use a USB drive or other methods to transfer the
Step 2: Install the Packages on the Offline Machine
Copy the files to the offline machine:
- Copy all the downloaded
.debfiles from your USB drive (or another medium) to a directory on the offline machine (e.g.,/tmp/openssh).
- Copy all the downloaded
Install the packages:
- On the offline machine, navigate to the directory where you copied the
.debfiles and install them usingdpkg:
bashcd /path/to/deb/files sudo dpkg -i *.debThis command will install the OpenSSH server along with its dependencies.
- On the offline machine, navigate to the directory where you copied the
Fix missing dependencies (if necessary):
- If there are any missing dependencies,
dpkgmight throw errors. You can resolve them by downloading the required dependencies manually (in the same way as above) or, if the dependencies are already available on the system, you can try fixing them with:
bashsudo apt-get install -f- If there are any missing dependencies,
Step 3: Enable and Start OpenSSH Server
Once the installation is successful, you can start and enable the SSH service:
Start the SSH service:
bashsudo systemctl start sshEnable SSH to start on boot:
bashsudo systemctl enable sshCheck the status of SSH:
bashsudo systemctl status ssh
Verifying the Installation
To verify that the OpenSSH server is running, you can check the listening ports:
bashsudo netstat -tuln | grep 22Try connecting to your machine using
sshfrom another machine in the network:bashssh username@remote_ip_address
By manually downloading and installing the required .deb packages, you should now have an offline Ubuntu machine running OpenSSH without using the apt package manager.
Ulasan