quoid
By:
quoid

SSH Asking for a password for certain commands

October 10, 2015 1.3k views
Security Getting Started Linux Basics Ubuntu

Probably goes without saying, but I am new to DO and everything involved with it.

I was setting up my first server and set up ssh and I can successfully ssh into my server.

Perhaps I don't yet have a firm enough grasp on SSH, but when executing certain commands, like sudo service fail2ban restart I am asked to input my password.

I was under, maybe the false, impression that when I SSH I wouldn't need to use my password. Am I incorrect? Is it perfectly normal to be asked for your password to execute certain commands even if you are SSH-ed into the server?

Thanks for the help, I apologize for any terminology misuse.

4 comments
  • Yes, it is normal. Anything that would ask you for a password normally (such as "sudo" and "su") will ask for it when using SSH too, unless you're using the root user with ssh (DON'T do this! you shouldn't allow root to log in via ssh)

  • @nixola

    unless you're using the root user with ssh (DON'T do this! you shouldn't allow root to log in via ssh)

    I'm logging in via SSH as a new user I created that has root privileges; is this what you are saying I shouldn't do? Or do you mean logging in as root?

    Thanks for the reply.

  • Hi quoid. What Nixola is saying is that yes, it is normal to have to enter a password every so often when executing commands such as the one you originally mentioned ( sudo service fail2ban restart ) ...I think the sudo user password is requested something like every fifteen minutes or so, as well as of course at the start of your session if you are entering a sudo command. How you are doing things is correct, in that you are using a new user with root privileges instead of using root. What Nixola was saying to you when referencing "don't do this", was basically saying use a sudo user and not the root account, because it is generally advised to disable the root account login after your new user has been created.

  • @newhosting2015

    Thanks for the reply and clearing that up. Seems, then, that I'm in a good spot!

1 Answer
asb MOD June 10, 2016
Accepted Answer

This question was answered by @newhosting2015:

Hi quoid. What Nixola is saying is that yes, it is normal to have to enter a password every so often when executing commands such as the one you originally mentioned ( sudo service fail2ban restart ) ...I think the sudo user password is requested something like every fifteen minutes or so, as well as of course at the start of your session if you are entering a sudo command. How you are doing things is correct, in that you are using a new user with root privileges instead of using root. What Nixola was saying to you when referencing "don't do this", was basically saying use a sudo user and not the root account, because it is generally advised to disable the root account login after your new user has been created.

View the original comment

Have another answer? Share your knowledge.