by Hao Chen
~1 min read

Categories

Tags

Linux

  1. how to set up ssh keys :door:

     # setup user login over ssh
     mkdir -p ~/.ssh
     touch ~/.ssh/authorized_keys
     # add your public key into authorized_keys 
        
     # disable password login
     # update value in /etc/ssh/sshd_config
        
     # To disable tunneled clear text passwords, change to no here!
     # PasswordAuthentication * => PasswordAuthentication no
     # PermitEmptyPasswords * => PermitEmptyPasswords no
     # ChallengeResponseAuthentication * => ChallengeResponseAuthentication no
     # UsePAM * => UsePAM no
        
     # disbale root login
     # PermitRootLogin * => PermitRootLogin no
     sudo systemctl restart sshd
    
  2. add a new user

     # Then add a new user that will be able to use sudo.
     useradd -m -G sudo <username> # (-m creates the home directory /home/user; -G adds the user to the sudoers group)
     # set the password for the new user
     passwd <username>
    
  3. sudo without password :door:

     sudo su -
     echo "`whoami`     ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/sudoers
     "`whoami` ALL=(ALL) NOPASSWD: NOPASSWD: ALL"