All cloud servers login comes with private key i.e. .pem key, which you will need to change the permission of the key first. Here’s how you normally SSH to the server:-
1) Change the permission of the private key
# chmod 600 keypair-SS0005117.pem
2) Then, ssh to the server using the given username & private key, default username is centos
# ssh 58.84.42.151 -l centos -i keypair-SS0005117.pem
3) Login as root
$ sudo su -
4) To change the ssh login to password authentication, simply go the below directory
# vi /etc/ssh/sshd_configand find the following lines. Search /Password
You will need to:-
- Un-comment the PasswordAuthentication yes
- Comment #PasswordAuthentication no
PasswordAuthentication yes #PermitEmptyPasswords no #PasswordAuthentication no
Save it.
5) Set the root password
# passwd root Changing password for user root. New password: Retype new password: passwd: all authentication tokens updated successfully.
6) Save & restart the service
# service sshd restart
Now here's how you want to allow username login as root, instead of centos.
7) Open new terminal, login using new password authentication details.
$ ssh 58.84.42.168 -lroot root@58.84.42.168's password:
8) go the below directory
# vi /etc/ssh/sshd_config
9) scroll to the bottom, search /centos. You have to comment #AllowUsers centos
in order to allow user login as root.
# Example of overriding settings on a per-user basis #Match User anoncvs # X11Forwarding no # AllowTcpForwarding no # PermitTTY no # ForceCommand cvs server AllowUsers root AllowUsers admin #AllowUsers centos
10) Save & restart the service
# service sshd restart