Setting a new user for login

March 24, 2015 851 views
Security Linux Commands Ubuntu


Unfortunatelly I cannot find a tutorial or question about this use case: once I created a user with root privileges, I want to configure my server in order to login only as this new user by default.

But still it is showing the user root by default -"Using username root" when it has yo say "Using name <my_new_uname>"-. I have to say that I've configured ssh keys in my server, and both users (the root and the new one) have their public keys in its respective locations.

How can I deal with this issue?

2 Answers

What command are you using to connect to the server? You should specify the user in the SSH command itself:

ssh new_username@your.ip.address

You can also disable root login via SSH altogether. Check out this tutorial for instructions on how to do that as well as some more common initial steps when setting up a new server:

by Justin Ellingwood
When you start a new server, there are a few steps that you should take every time to add some basic security and give you a solid foundation. In this guide, we'll walk you through the basic steps necessary to hit the ground running with Ubuntu 14.04.
  • Hi @asb
    Thanks for your answer.

    Well I was using putty for connections and by default always I connect to my droplet directly without specifying a user: just my IP address withour the username and "@".
    In this scenario the console prompted message "Using username root".

    But i don't want to see this user as the proposed user for start any session.

    In another server I found this config in the /root/.ssh/authorized_keys:

    no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command="echo 'Please login as the user \"ubuntu\" rather than the user \"root\".';echo;sleep 10" ssh-rsa <pubkey_string> <pubkey_comment>

    Setting this way, and assuming that you previously changed the line PermitRootLogin no with PermitRootLogin without-password helps to block login for root. And also to force to use SSH keys.

    Also I saw in another terminals -where you directly start your session passing the IP address without the user to connect- that prompts message "login as:" in order to put the username who wants to connect. But I'm checking in which part of the config files is located this command or message proposal.

Have another answer? Share your knowledge.