You have 2 easy ways to achieve this:
- You allow the root user to login through ssh, you can do this by editing the
/etc/ssh/sshd_config file and setting the
PermitRootLogin to true, this will allow root to connect through ssh.
- You create a custom script for your ssh user to automatically login as root. This can be done through the
/etc/passwd file, you will notice your user will look something like :
To run a custom script on login, you would change the
/bin/bash portion and add your own script that will run whatever code you want, this can include something like sudo -s and then at the end of your custom script you can also call
/bin/bash again I believe, so your
passwd would look something like:
Beware that the second option will impact your ssh login behaviour, so for you to test this, make sure that you can deal with making a mistake and effectively being unable to log in with your user, so make sure you have a backdoor ssh access through another user or root as mentioned in option 1 at least temporarily for you to log back in and correct any mistakes until you have the setup working.
Update: Following up on comments below, it is worth mentioning this does not only affect the ssh login but any login of that user (I've approached this assuming that your requirement is for this user always to login as root and you don't wish to allow the actual root user to log in through ssh). It is also worth noting that this is as easier solution to what could be a much tighter and complex one that would apply to SSH only, your question doesn't go into a lot of detail.
As mentioned in the comments, you could also achieve this same behaviour through
/etc/ssh/sshrc I just prefer to edit the raw /etc/passwd so that in the future it is very evident what is happening and it requires you to accomodate for the consequences, while
sshrc is great but makes future troubleshooting a litle harder if you happen to forget how you have set up the system which let's be honest, happens a lot.
But it is indeed a good habit to have to not expose the root user at all, this will give you much more flexibility in the future and to try things and to custom your sudoer permissions.
Hope this helps