I accidentally added my root user to my sftp group using command:
sudo usermod -a -G sftp ubuntu
And now everytime I tried to login my linux server it shows this error: 
I do not have any other users in the server. How do I fix it?
I accidentally added my root user to my sftp group using command:
sudo usermod -a -G sftp ubuntu
And now everytime I tried to login my linux server it shows this error: 
I do not have any other users in the server. How do I fix it?
Since you are working with an AWS EC2 instance, you really only have one option for recovery: stopping the instance, mounting the EBS volume to another EC2 instance, and then manually modifying the /etc/group file to remove the ubuntu user from the sftp group.
AWS provides instructions on how to mount the EBS volume onto another EC2 instance at this documentation link. In the interests of fighting link-rot the steps are:
To attach an EBS volume to an instance using the console
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
In the navigation pane, choose Volumes.
Select the volume to attach and choose Actions, Attach volume.
Note
You can attach only volumes that are in the Available state.
- For Instance, enter the ID of the instance or select the instance from the list of options.
Note
The volume must be attached to an instance in the same Availability Zone.
If the volume is encrypted, it can only be attached to instance types that support Amazon EBS encryption. For more information, see Amazon EBS encryption.
For Device name, enter a supported device name for the volume. This device name is used by Amazon EC2. The block device driver for the instance might assign a different device name when mounting the volume. For more information, see Device names on Linux instances.
Choose Attach volume.
Connect to the instance and mount the volume. For more information, see Make an Amazon EBS volume available for use on Linux.
After you have removed the ubuntu user from the sftp group, you can disconnect the volume from the EC2 instance you were working on, start up the original EC2 instance that had the error, and SSH to it normally.
Don't login as root. Login as your administrative user and use sudo -s to get a root shell.
Failing that, boot a rescue image and use that to reset root's groups membership