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-server
package and note the dependencies for the version that matches your Ubuntu version.
Download the required
.deb
packages:- On the online machine, download the necessary
.deb
files foropenssh-server
and its dependencies. You can either manually download them from the Ubuntu Packages website or useapt
on an online machine to download the packages:
bashsudo apt update sudo apt download openssh-server
This command will download the
openssh-server
package and save the.deb
file 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-server
This will download the
.deb
files foropenssh-server
and all its dependencies to the current directory.- On the online machine, download the necessary
Transfer the downloaded
.deb
files:- Use a USB drive or other methods to transfer the
.deb
files 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
.deb
files 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
.deb
files and install them usingdpkg
:
bashcd /path/to/deb/files sudo dpkg -i *.deb
This 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,
dpkg
might 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 ssh
Enable SSH to start on boot:
bashsudo systemctl enable ssh
Check 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 22
Try connecting to your machine using
ssh
from 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