I'm trying to ssh as root to an rpi but it does not work

I have installed the openssh server on RaspberryPi and want to login to the Pi using laptop but it is not working.
I get

permission denied, please try later

when trying to login through laptop.
I have enabled ssh service, also I enabled ssh from the firewall blocking.

1 Like

You installed sudo apt install openssh-server. Are you trying to login as root? it will not allow it, you have to look in /etc/ssh/sshd_config for the line #PermitRootLogin prohibit-password

But you should be able to ssh with user pi and its password.


Welcome @Ujur007 to the community!

1 Like

Ok. I made PermitRootLogin to yes and now it lets me do ssh. So that was the issue. Unfortunately, I did not find this information on other online forums.

you should not ssh as root, you can ssh as user pi and then if you need root, use sudo.

Also, your title should have read, "I'm trying to ssh as root to an rpi but it does not work."
Details matter when you describe an issue.

ssh works and has worked since the beginning of the Internet, one of the most valuable tools.


Is there a documentation on this topic? As there is also a long topic related to key exchange and security. Which confuses me.
I looked online on some forums which did not help as the information there was quite different from one topic to another.

Yes, type in a terminal:

man sshd
man sshd_config
man ssh-keygen

Each command will show you extensive documentation on the ssh service.

b.t.w. Ubuntu-MATE, like other distros, has this way of documentation build in for almost every command.


Thanks for the explanation.

By the way, I am looking for something specific. Let's say I want to do port forwarding and I have to edit some files etc. and follow some specific steps. There are many online tutorials on that. How can I do it myself? or know which files I need to edit? Any offline recommendation i.e. books will also work.

That is a question that needs quite an extensive answer.

I assume that you want to know how to discover functionality on your computer in general and what strategy to follow to accomplish that, by using portforwarding as an example.
(If I'm mistaken about that, please let me know)

Port forwarding assumes that you know that you need a firewall.

Ofcourse this is on Ubuntu done by 'ufw' and 'gufw'.
If you want to know how to use 'gufw', open the manpage:

man gufw

Which, aside from the regular stuff, shows a link to a 'quick setup' page:

But suppose that you don't know about ufw or iptables and want to discover for yourself what your system has to offer.

You can use this steps to get what you need to get going.
This is roughly the same for every functionality or application that you want to findout about.

1. from the terminal

The 'apropos' command returns anything it deems appropriate as answer to a random keyword. In this case 'firewall'

apropos firewall


ufw (8)              - program for managing a netfilter firewall

To see if it exists on your system:

apt search ufw

results in

Sorting... Done
Full Text Search... Done
gufw/jammy,jammy,now 22.04.0-0ubuntu1 all [installed,automatic]
  graphical user interface for ufw

plasma-firewall/jammy 5.24.4-0ubuntu1 amd64
  Plasma configuration module for firewalls

ufw/jammy-updates,jammy-updates,now 0.36.1-4ubuntu0.1 all [installed,automatic]
  program for managing a Netfilter firewall

This shows you the components you need and even if they are installed or not.

Also read the manualpage:

man ufw

and search for rule syntax.
(in man pages the searchcommand is a slash)

/rule syntax

the 'Search again' command is just a bare slash

instead of entering the rules in terminal, you might want to use a graphical frontend for ufw.

'apt search ufw' has shown that 'gufw' is the graphical frontend.
If it is not already installed, you might want to do so.

2. Another way is to install synaptic.

This packetmanager is perfect to do random searches for needed functionality. Use the search function to search for 'firewall'

3. The best way is to 'get' how the underlying Linux system is structured

A good overview and considered a standard work is this book:

Linux in a Nutshell, 6th Edition [Book]

Which will let you discover that 'iptables' is the base of practically all firewalls.

General Info

The desktop part ( MATE ) follows the freedesktop.org guidelines c.q. standard. You can find more about it here:

On Linux in general, all system/systemwide configuration files can be found in files and folders under '/etc/'

user configuration files for installed applications on modern desktops should be found under "$HOME/.config/" (freedesktop.org guideline)

older applications sometimes put their user-config as hidden file or folder in "$HOME"

I think that's about it in a nutshell.
I don't know if this answers your question.
Let me know, ok ?

EDIT: I almost forgot -> Books | Ubuntu MATE


@pavlos_kairis is correct: Ubuntu does not allow to login into its console as root user nor using ssh nor directly. One has to login as a regular user and use his sudo privileges to perform administrative tasks.


Thanks for the update and long explanation.
What I would like to read or looking for is not just the Linux commands but actually how everything is organized. Imagine a RTOS(Real-time operating system) used for microcontrollers where there are multiple things like configuration files, libraries, applications, API references etc. And above them there is a build system which takes care of how evrything is built and combined into one executable.

So it gets easier for someone to understand how it works. In case of Linux or Ubuntu let's say I am not finding something like that. Then I am left to mere online steps and guides where others have mentioned how they did something without me undestading the internals on Linux.

1 Like

So you actually need a primer of the underlying Linux system.
This book is targeted towards that.

You can find an online version with some google magic. :wink:

There is no 'one book to rule them all'
Since a Linux distro is a bunch of cleverly collected pieces of unrelated software, the documentation consists mostly of fragmented pieces of information. One website that tries to collect all this info in one place is The Linux Documentation Project

The first thing you want to do is to know where you can expect to find configfiles and the like. So read this manpage:

man hier

Since the only solid factor in a distro is the kernel (everything else is in a continuous flow of change), you won't find an ultimate guide to the architecture of linux systems easily. It is just a kernel with a lot of things bolted on in any way that it could fit.

Linux based operating systems are normally not really 'designed' but more or less 'anarchisticly evolved' (with warts and all) so some things are a bit messy.

Different distros can differ immensely in their structure. (think about the difference between your laptop, your android-phone and your router, all running linux).

The only common denominators are

  1. the huge monolithic kernel (including TCP/IP stack) and the drivers (modules) all residing in kernelspace.
  2. the virtual filesystem (kernelspace)
  3. the huge amount of available API's to let layers of userspace cruft communicate with eachother.

(A proper designed OS would be OpenBSD or any of the BSD derivatives.
Linux is more like LEGO. Imagine a bunch of kids building a LEGO house together. the result may be practical but is seldom a thing of beauty or design finesse)

If you really want to know how everything works under the hood, or gain insight in how all the parts connect, you should try to install several 'difficult' distro's because you will learn a lot of things that are usually not talked about. The installation guides of these 'DIY' distros are extremely good.
(I regularly use the Arch linux site as troubleshooting guide.)

In order of ascending difficulty/work (and ascending gain of knowledge for you) :

  1. Arch Linux
    (manual install with binary packages from repository)
  2. Gentoo linux
    (manual install with sourcecode packages from repository; compiles in situ)
  3. Linux from scratch (LFS)
    (no package manager. Get the sources yourself and compile.
    Since nothing is installed automatically; you install, configure and setup everything yourself. This gives an irreplacable insight in the inner workings of the system.)

If you build LFS just once, you will know practically everything about Linux.

EDIT: These webpages may answer a part of your question
Architecture of Linux - javatpoint
Conceptual Architecture of the Linux Kernel

1 Like


Actually, after successful login via SSH during the last weeks, what I was trying was to form a Wireless hotspot so that I could share the internet with other computers.
My setup is the following.

I have a Raspberry Pi4 running Ubuntu-mate with PoE Hat on it. The ethernet cable is connected to the Router with internet access. I want to create a wifi -hotspot.

For that, first, obviously, I tried the GUI method which did not work(to provide internet. of course, I was able to connect to the wifi access point.) perhaps because ethernet is not configured to have internet access.

Then I followed some guides on the Ubuntu website which seems not working at the moment.

Does anyone has an idea where to look for help?