Skip to content

Instantly share code, notes, and snippets.

@ijash
Last active October 23, 2019 08:15
Show Gist options
  • Save ijash/a6dbc83b7c0ea842f3b7da95d124e6a4 to your computer and use it in GitHub Desktop.
Save ijash/a6dbc83b7c0ea842f3b7da95d124e6a4 to your computer and use it in GitHub Desktop.

Enable root account for SSH & SFTP login

Warning: This method might be unsafe for server users.

Ubuntu doesn't allow root user and also login in ssh as root by default. But sometimes, remote sftp login has better convenience in editing the system files such as nginx config so it can be edited in GUI. As a precaution, This method is not recommended in production for security reason. So the first thing you have to do is:

  1. Enable your root user account in remote server:
    sudo passwd root
    
  2. Fill in your password.
  3. Root account is enabled now. Make sure openssh-server is installed and be able to edit the ssh config:
    sudo nano /etc/ssh/sshd_config
    
  4. Find the line contains PermitRootLogin no, modify it to PermitRootLogin yes. or just add it.Now restart the ssh server:
    sudo service ssh restart
    
  5. Now give it a try by using ssh root@remotehost from your computer to the server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment