Reinstall Ubuntu remotely using SSH
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Muhammad Hussein Fattahizdeh 3a1c466d5a add more info 4 years ago
LICENSE Initial commit 5 years ago add more info 4 years ago
config.sample add more info 4 years ago add more info 4 years ago init 5 years ago fix readme config 5 years ago
preseed.cfg.template add more info 4 years ago

Ubuntu Overssh Reinstallation

If your ISP/Datacenter dosn't provide standard or trusted iso for your server. Get ugly server from it with installed version of Ubuntu server.

I have same situation installed ubuntu has bad partition table or huge list of stupid package installed. Datacenter network is my primary concern or it's really cheap price but administrators dosn't care. What should i do? That's my way to solve this issue easily.

Ask them to install ubuntu server what ever is it. re install it over ssh.

Create your own netiso and reinstall it over ssh. You can partion yor server as you desire. And set more configuration using ubuntu preseed just over ssh; no kvm/ipmi/vnc required.


  1. Installed ubuntu version on server via ssh access
  2. Clone this repo to your server
  3. Copy config.sample to config file and edit field by field exactly:
    # country
    # network: check network before create iso file
    # preseed file: upload created preseed.cfg to your own host before reboot system
    # ssh installer password
    # hostname and domain
    # lowercase of country code dont change it
  4. Upload your preseed.cfg file to your own host.

Find Predictable Network Interface Names

If your current installation of ubuntu not using Predictable Network Interface Names you can find out the name by using this command for example for eth0:

udevadm test /sys/class/net/eth0 2>/dev/null | grep ID_NET_NAME_

You can use enp7s0 as predictable network interface name.

Clone repository

cd /tmp
git clone
cd ubuntu-overssh-reinstallation


See config.sample and change it. ⚠ Carefull about your network settings. It's can hold your server until get new kvm/ipmi/vnc to restore the ssh again.

cp config.sample config
vim config

Download network mini iso from ubuntu website


Build iso

Remember you must do as root user

Your network iso is ready '/tmp/ubuntu-overssh-reinstallation/ubuntu-overssh-reinstall.iso'

Update grub imageboot

Remember you must do as root user also

Your password is tHISiSpASSWORD

Upload your preseed file

Upload your preseed.cfg file to configured location PRESEED_URL.

You can test it. We must get 200 response as we expected

curl -o /dev/null --silent --head --write-out '%{http_code}\n' http://yourserver.tld/preseed.cfg

⚠ If your webserver not reachable you must reboot your server to get preseed file. so test it before reboot your server.



Get ssh

Wait it until boot to iso complete and install require packages then

ssh [email protected]

Continue installation of ubuntu

This script test on Ubuntu Server 16.04 and 18.04.