how to disable password and root ssh?

Thufir

I've restarted ssh with sudo systemctl restart ssh on xenial 16.04 LTS running a VPS on AWS EC2, yet still get prompted for a password when connecting with ssh. How can I disable root ssh and disable password login?

ubuntu@ip-xxx-xx-x-xx:~$ cat /etc/ssh/sshd_config 
# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
#PermitRootLogin prohibit-password
PermitRootLogin no
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication yes

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes




AllowUsers thufir ubuntu


DenyUsers root
ubuntu@ip-xxx-xx-x-xx:~$ 

Both allowed users belong to the sudo group.

The log at /var/log/auth.log shows:

sshd[2035]: Accepted keyboard-interactive/pam for thufir from xxx.xxx.xxx.xxx port 43986 ssh2

Jakuje

how to disable password and root ssh?

Lets rephrase it and I except you want

  • Deny all root login
  • Deny all password logins for all users
  • Allow other users with other authentication methods (publickey)

This is achieved using below configuration options:

PermitRootLogin no
PasswordAuthentication no
ChallengeResponseAuthentication no

If you change your config to have these (not append to the end!) and restart your server, you should achieve the above. If not, please, clarify the question and post the logs as asked already.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Disable password authentication for SSH

From Dev

How to reset password for root in arangodb?

From Dev

What is the password for ``ssh root@localhost``?

From Dev

How do I disable remote SSH login as root from a server?

From Dev

Docker: cannot set a password for root (ssh access)

From Dev

What is the password for ``ssh root@localhost``?

From Dev

How to disable the try again password in ssh command

From Dev

How to disable WSL password?

From Dev

Disable SSH password authentication on specific interface

From Dev

How do I disable remote root login via ssh?

From Dev

Disable root password caching

From Dev

How to permanently disable root-password prompt for recovery mode, RHEL7

From Dev

How to permanently disable root-password prompt for recovery mode, RHEL6

From Dev

how to make non-root user to ssh using key instead of password?

From Dev

Synology SSH Root password does not work

From Dev

How to disable password prompt from ssh client side?

From Dev

SSH password script using root

From Dev

script ssh login to server and pass root password

From Dev

How do I disable remote SSH login as root from a server?

From Dev

How do I completely disable password ssh logins?

From Dev

ssh disable password authentication

From Dev

How to disable root privilege for SSH'ed users?

From Dev

How to disable running Firefox as root without password Linux?

From Dev

Disable ssh password authentication programmaticaly

From Dev

Disable SSH password on Ubuntu virtual machine

From Dev

How to keep password aging but disable password "inactive"?

From Dev

Command to disable password login via ssh?

From Dev

Disable password access through SSH?

From Dev

What is the correct way to disable SSH password authentication

Related Related

  1. 1

    Disable password authentication for SSH

  2. 2

    How to reset password for root in arangodb?

  3. 3

    What is the password for ``ssh root@localhost``?

  4. 4

    How do I disable remote SSH login as root from a server?

  5. 5

    Docker: cannot set a password for root (ssh access)

  6. 6

    What is the password for ``ssh root@localhost``?

  7. 7

    How to disable the try again password in ssh command

  8. 8

    How to disable WSL password?

  9. 9

    Disable SSH password authentication on specific interface

  10. 10

    How do I disable remote root login via ssh?

  11. 11

    Disable root password caching

  12. 12

    How to permanently disable root-password prompt for recovery mode, RHEL7

  13. 13

    How to permanently disable root-password prompt for recovery mode, RHEL6

  14. 14

    how to make non-root user to ssh using key instead of password?

  15. 15

    Synology SSH Root password does not work

  16. 16

    How to disable password prompt from ssh client side?

  17. 17

    SSH password script using root

  18. 18

    script ssh login to server and pass root password

  19. 19

    How do I disable remote SSH login as root from a server?

  20. 20

    How do I completely disable password ssh logins?

  21. 21

    ssh disable password authentication

  22. 22

    How to disable root privilege for SSH'ed users?

  23. 23

    How to disable running Firefox as root without password Linux?

  24. 24

    Disable ssh password authentication programmaticaly

  25. 25

    Disable SSH password on Ubuntu virtual machine

  26. 26

    How to keep password aging but disable password "inactive"?

  27. 27

    Command to disable password login via ssh?

  28. 28

    Disable password access through SSH?

  29. 29

    What is the correct way to disable SSH password authentication

HotTag

Archive