How to enable root login on SSH with preseed

Asked by Kory Davids

Greetings all.

My question seems SIMPLE but i have yet to figure this out.

I work for a datacenter and we install 14.04 often. And i am wondering if there is a way to set it up in a preseed file that root logoin is permited in SSH?

we have to go into /etc/ssh/sshd_config and change PermitRootLogin to yes.

I know it is not that hard to do, but would like to eliminate one step in the process.

Any help on this would be great.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

You need to set a root password too. By default the account is disabled. I recommend a command at the end of your process to re-disable the account for security.

Revision history for this message
Kory Davids (kory-s-davids) said :
#2

We have to account enabled.

We just need to be able to permitrootlogin in ssh

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#3

Did you restart the SSH service after editting the config file?

You could run a watch on /var/log/auth.log to see what happens when you try to connect.

Revision history for this message
Kory Davids (kory-s-davids) said :
#4

If we go in and manually change PermitRootLogin to yes, everything works fine. I am looking for a way to have it change that in the preseed file.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#5

You could have a command in the seed command using passwd and expect to set the password on the account.

Revision history for this message
Thomas Krüger (thkrueger) said :
#6

One additional remark:

The root login has been deactivated in Ubuntu for a reason. Everything should be none as a user in the sudo group with the sudo command. This gives an additional layer of security.
Also when the root access is _really_ required, you should limit it to public key login only. No passwords.

Revision history for this message
Ludovic Francois (lfrancois) said :
#7

Did you find an answer? I am looking to do exactly the same thing, I am new with preseed, looking for the best way to update /etc/ssh/sshd_config :)

Revision history for this message
Orivej Desh (orivej) said :
#8

Add this to your preseed:

d-i preseed/late_command string \
    in-target sed -i 's/PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config

Can you help with this problem?

Provide an answer of your own, or ask Kory Davids for more information if necessary.

To post a message you must log in.