1. Home
  2. Connecting to your Server
  3. Resetting the Root Password for a Dedicated Server

Resetting the Root Password for a Dedicated Server

To reset the root password for a Dedicated Server, you will need to start it in the network boot (‘netboot’) environment. This will require a short period of downtime.

Please follow the relevant section below, depending on what type of operating system your server is running.

‘Netbooting’ a Dedicated Server

Dedicated Servers can be rebooted from the serial console. The connection to the console is made using a key file instead of a password. Your key file is stored in the /root/ directory of your server before delivery (the welcome email tells you this).

If you have lost your SSH key you can contact support to get a new one issued, or you can provide us with a public key you’d like us to use.

Once you have this file eg. stoneboat.dh.key, you would connect to the console by typing:

ssh -i stoneboat.dh.key dhshell@stoneboat.dhadmin.bytemark.co.uk

ie. the username is dhshell and the server name should be stoneboat.dhadmin.bytemark.co.uk.

Please note that, OpenSSH, the most common SSH program on Linux or Mac OSX, requires the permissions on the key file to be 0700. If your key has different permissions, you will receive a prompt for a passphrase, even if one has not been set. You can update the file permissions by running:

chmod 0700 stoneboat.dh.key

Dedicated Servers will offer to network boot before they try their hard drives. After power-cycling the server from the console, you should see the following menu within 30 seconds (Premium Dedicated Servers will take a few minutes):

If you ignore this prompt for 10 seconds (or just press Enter), your server will boot normally. To start the network boot environment type netboot and press Enter.

Process for servers running Linux

Mounting your drives

Once you have started your server in the netboot environment, you will need to mount your drives by running the following commands:

mkdir target
mkdir target/boot
mount /dev/md1 /target
mount /dev/md0 /target/boot

(For premium machines with hardware RAID, or some non-standard software RAID configurations the device names will differ. Please contact support if you are unsure.)

Accessing your file system

To run programs on your real file system you will need to run the command:

chroot /target

This gives you a prompt ‘inside’ your normal system.

Changing your root password

Now you have access to your file system, you can change your root password by running the following command:

passwd root

You will be prompted to enter the new root password you want to use. It is normal for nothing to be displayed on the screen as you type your password. You will be asked to enter your password for a second time to confirm you typed it correctly. You should receive the message ‘passwd: password updated successfully‘ when this is complete.

Unmounting your drives and rebooting your server

To unmount your drives and reboot your server, run the following commands:

umount /target
umount /target/boot exit reboot

Process for servers running Windows

  1. Restart your server in the ‘netboot’ environment.
  2. Add support for the NTFS file system by running the following command:
    apk add ntfs-3g
    
  3. Create a directory called ‘target‘, mount your drive there and navigate to the ‘System32‘ directory.
    mkdir target
    mount -t ntfs-3g /dev/sda2 /target
    cd /target/Windows/System32
    

    Note: If the mount command fails, try running it with -o force on the end

  4. Temporarily replace the ‘Magnify.exe‘ executable so it opens a command prompt instead:
    mv Magnify.exe Magnify.bak
    cp cmd.exe Magnify.exe
  5. Unmount your filesystem and reboot the server by running the following commands:
    cd /
    umount target
    exit
    reboot
  6. When the Windows login screen appears, click the ‘Ease of access‘ icon (bottom left) and click ‘Magnifier‘ which should now open a command prompt.
  7. Reset your password by running the following command, replacing password with the new password you want to use:
    net user administrator password
  8. Login to check the new password works.
  9. Once you have confirmed you can login successfully, netboot your server and rename the ‘Magnify.exe‘ executable by running:
    mv Magnify.bak Magnify.exe
Updated on November 8, 2018

Was this article helpful?

Related Articles

Have you tried Kubernetes?
Kubernetes (K8s) is helping enterprises to ship faster & scale their business. Sounds good? Let us build a K8s solution for your needs.
Register your interest