How to setup root password with ssh only

I've checked out related topics but didn't find the answer for me. Recently I set up a router with RPi 4B, until I found today that I forgot to setup a root password for it.

Before RPi 4B all routers I've experienced with has a Luci interface for it, which let me totally lost on this 'easy' part without Luci.

What's the proper way to setup a password using ssh only?

Type passwd, press enter and type in the new password twice.