How to Enable and Disable Root Login via SSH on Ubuntu

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ม.ค. 2025

ความคิดเห็น • 38

  • @s.gardner7576
    @s.gardner7576 2 ปีที่แล้ว +1

    A major point worth mentioning is to make sure there is no "#" sign in front of "PermitRootLogin no" or AllowUsers if needed. Basic but very necessary for this to work. Especially for viewers new to Linux.

    • @TonyTeachesTech
      @TonyTeachesTech  2 ปีที่แล้ว +1

      Thanks for pointing this out

    • @DHRUUVable
      @DHRUUVable 2 ปีที่แล้ว +3

      You don't know what this comment has done to me. I can't thank you enough. I was stuck in this from whole day and never noticed that # shouldn't be there. God!! thank you so much.

  • @benjibeatsboy
    @benjibeatsboy 3 ปีที่แล้ว

    Hello man, What if the sshd_config does not exist? In my case it does not exit. What can I do?

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว +1

      Maybe you have to install it first?
      apt install openssh-server

    • @benjibeatsboy
      @benjibeatsboy 3 ปีที่แล้ว +1

      @@TonyTeachesTech thanks I will try

  • @suryatejaswi659
    @suryatejaswi659 4 ปีที่แล้ว +1

    Thanks man i didnot have that allowusers line in the file so i was looking whatsgoing wrong ,thanks again

    • @TonyTeachesTech
      @TonyTeachesTech  4 ปีที่แล้ว

      You can simply add this line if it isn't there

  • @jackt6112
    @jackt6112 ปีที่แล้ว

    I've done this same procedure countless times in UNIX and AlmaLinux and it worked perfectly. I'm doing it in Linux Mint being used as an Internet server and this procedure does not work. I''ve tried from both the public and private vlan interfaces. I can log in as a regular users, but not as root. Yes, sshd has been restarted and I even rebooted. I can RDP in as root and launch terminal, but not ssh as root. Weird!

  • @alexander.k94
    @alexander.k94 6 หลายเดือนก่อน

    When i type root@myip it requires password. Any ideas?

  • @vilaskhadka2626
    @vilaskhadka2626 3 ปีที่แล้ว

    after rootpermit no done if we have to do some major changes in system then how we can login in root.

  • @dennyi.s.7860
    @dennyi.s.7860 3 ปีที่แล้ว

    how to save the line changes ?, i press ctrl X nothing changes

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว +2

      Press Esc then type :wq and hit Enter th-cam.com/video/uE4aljoMBeg/w-d-xo.html

    • @dennyi.s.7860
      @dennyi.s.7860 3 ปีที่แล้ว +1

      Thanks, well noted. You are the best

  • @afriendlynorwegianguy3284
    @afriendlynorwegianguy3284 3 ปีที่แล้ว

    i am trying to enable root login via ssh and i have said yes to permitrootlogin thing and restarted the service and server, but it does not alow me to login. any tips?

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว

      Does your /etc/ssh/sshd_config file still have permitrootlogin enabled?

    • @afriendlynorwegianguy3284
      @afriendlynorwegianguy3284 3 ปีที่แล้ว

      @@TonyTeachesTech yes it does

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว

      @@afriendlynorwegianguy3284 Do you also have AllowUsers root like here 1:37

    • @afriendlynorwegianguy3284
      @afriendlynorwegianguy3284 3 ปีที่แล้ว

      @@TonyTeachesTech no I don't, il try that tomorrow as it is quite late here In Norway:) thanks for the help

  • @BMAPS
    @BMAPS 3 ปีที่แล้ว

    Tried this on ubuntu EC2 instance, showing permission denied (publickey)

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว

      I'm not too familiar with EC2 right now, but do you know if EC2's have ssh enabled by default?

    • @BMAPS
      @BMAPS 3 ปีที่แล้ว

      @@TonyTeachesTech yes they do

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว

      @@BMAPS Is it port 22?

    • @BMAPS
      @BMAPS 3 ปีที่แล้ว

      @@TonyTeachesTech yes port 22 is enabled

    • @TonyTeachesTech
      @TonyTeachesTech  3 ปีที่แล้ว

      @@BMAPS In that case, I don't know. I'm guessing there is an issue with your key.

  • @limamey4175
    @limamey4175 4 ปีที่แล้ว

    Hello what program do you use in the video?

    • @TonyTeachesTech
      @TonyTeachesTech  4 ปีที่แล้ว

      On my MacBook, I am using the built-in Terminal program

  • @leonardthek6802
    @leonardthek6802 2 หลายเดือนก่อน

    thank you!

  • @juniorthian2370
    @juniorthian2370 3 ปีที่แล้ว

    Great !!!

  • @bluestreak711
    @bluestreak711 4 ปีที่แล้ว

    I followed the instructions and got this to pop up, but I do not see the allowed users part. "#MaxSessions 10
    #PubkeyAuthentication yes
    # Expect .ssh/authorized_keys2 to be disregarded by default in future.
    AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
    #AuthorizedPrincipalsFile none
    #AuthorizedKeysCommand none
    #AuthorizedKeysCommandUser nobody
    # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
    #HostbasedAuthentication no
    # Change to yes if you don't trust ~/.ssh/known_hosts for
    # HostbasedAuthentication
    #IgnoreUserKnownHosts no
    # Don't read the user's ~/.rhosts and ~/.shosts files
    #IgnoreRhosts yes
    # To disable tunneled clear text passwords, change to no here!
    #PasswordAuthentication yes
    #PermitEmptyPasswords no
    # Change to yes to enable challenge-response passwords (beware issues with
    # some PAM modules and threads)
    ChallengeResponseAuthentication no
    # Kerberos options
    #KerberosAuthentication no
    #KerberosOrLocalPasswd yes
    #KerberosTicketCleanup yes
    #KerberosGetAFSToken no
    # GSSAPI options
    #GSSAPIAuthentication no
    #GSSAPICleanupCredentials yes
    #GSSAPIStrictAcceptorCheck yes
    -- INSERT -- 44,1 41%
    "

    • @TonyTeachesTech
      @TonyTeachesTech  4 ปีที่แล้ว +1

      Oh that's okay. Feel free to add this line if it does not exist

  • @nameeralketti5734
    @nameeralketti5734 2 ปีที่แล้ว

    Thanks

  • @Eggsec
    @Eggsec 2 ปีที่แล้ว

    So I'm working on an assessment, I was able to find the root password using Medusa.
    Now, I'm trying to ssh roo@××.xx.xx.xx. I get permission denied (publickey)
    I think I found my answe watching you video.
    Is there another way to get my footin with knows ssh credentials?