1

I'm able to connect WinSCP session to Google Cloud Project's Compute Engine instance, but only as a user (from the sudoer group). Which doesn't let me change any files.

And through a PuTTY terminal also, I'm only able to first connect as a normal user, then every time I connect, then I've to give the command sudo -i to change to root user. If I try to connect directly as a root user, I get a 'permission denied' error message.

Isn't there a way to connect as root in both of the cases? (root in WinSCP is much needed, as there is no way to change as root later on).

1 Answers1

0

Enabling the root user is not recommended.

I recommend creating a firewally (security group) rule that only allows access to port 22 from your public IP address or CIDR block.

To enable the root user, you need to modify the SSHD configuration. The exact file and feature depend on the operating system.

For most Linux system:

  • Edit /etc/ssh/sshd_config
  • Change this line to PermitRootLogin yes or PermitRootLogin without-password or PermitRootLogin prohibit-password. The exact one to use depends on your setup (username/password or only SSH keypairs), the OS and version.
  • Restart SSH: service ssh reload

These changes must be done as root or sudo each command. These changes only affect new connections.

Note: Make sure that you have a backup (snapshot or image) of your system before making changes. Mess up SSH and your system access will be gone.

The above changes allow the root user to login. They do not specify the method to login. The simplest method is to copy your public key stored in your account on that system to the root user:

mkdir /root/.ssh
cp /home/myusername/.ssh/ /root/.ssh/

Now you can login with the same private key with the username root.

I recommend create a new keypair for the root user.

John Hanley
  • 4,287
  • 1
  • 9
  • 20