How to log in as Root user on your Raspberry Pi server

Installing Vim

Start by logging into user pi via SSH as we’ve done in previous tutorials.

Next we are going to update our apt-get package lists.

sudo apt-get update

This command downloads the package lists from the repositories and “updates” them to get information on the newest versions of packages and their dependencies.

Now you can download Vim.

sudo apt-get install vim

Vim is a command line text editor that allows you to edit text files without ever leaving the command line. Vim uses a series of commands in order to traverse a file and make changes. I wont be able to explain Vim in detail here as it is a deep and complex subject unto itself. Thankfully we will only need the basics for the following tutorial.

Log in as root user

In order to log in as the root user of the raspbian OS we must first edit the config of SSHD. To do this:

sudo vim /etc/ssh/sshd_config

This will open the sshd_config file within the vim text editor.

Press ‘i’ to switch to insert mode within Vim. This will allow you to make changes to the file. If you do not know how to use the Vim keybindings you can use the arrow keys to traverse the file.

Find the following line:

PermitRootLogin without-password

make edit as follows

PermitRootLogin yes

Press ‘esc’ and then type ‘:w’ in order to write to the file (save changes to the file). Then type ‘:q’ and press enter to exit and return to the terminal.

Restart the SSHD service with the following command.

/etc/init.d/ssh restart

In order to log in as the root user we need to set a password for root.

sudo passwd root

This will prompt you to enter a password for root. Use a simple password for now as this will only be a temporary measure. We will be disabling this feature once we have created a new user.

We can now exit our session and log in as user ‘root’.

exit

You can log in as root the same as any other user .

ssh root@<ip-address>
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.