Site icon mulcas

Connect to an Ubuntu server as a root using WinSCP

Connect to an Ubuntu server as a root, using WinSCP

Using WinSCP is one of the most popular ways to transfer files to a remote Linux server. In this post, I will explain how to connect to an Ubuntu server as a root using WinSCP. First, it is important to note that the root user is not directly accessible with a login operation in Ubuntu and other Linux distributions. Using an unprivileged user as an intermediate login is the first step.

Background

Windows customers can download WinSCP for free and use it as an SFTP client, FTP client, WebDAV client, S3 client, or SCP client. Its primary function is to transfer files between local and remote computers. Additionally, WinSCP supports scripting and basic file management.

If you are using WinSCP to access the root folder, create a new folder (directory), or simply transfer files, you might see one of the following errors if you don’t access it using the root account. 

This error happens due to the current user doesn’t have the root rights and permissions will be denied. 

Keep in mind, that for accounts such as root, the direct login is typically disabled by default for security reasons. So when enabling it, have security in mind. And also, you can’t change to a root account in WinSCP when you are already logged into a session, as you can do in the Linux shell using su.

Note: This solution also works for AWS EC2 instances.

Connect to an Ubuntu server as a root using WinSCP

Before continuing, we need to make sure about some obvious things in our Ubuntu server:

Option 1

This is the most common option that you’ll see around…

@Your Ubuntu Server

user ALL = (ALL) NOPASSWD: ALL

@Local Machine WinSCP

 sudo su -

Option 2

With option 1, you might get another error:

Error skipping startup message. Your shell is probably incompatible with the application (BASH is recommended)

This could be your case, or you just can’t manage to get option 1 to provide root access to your server. In any case, try this option 2. 

@Your Ubuntu Serve

ALL=NOPASSWD: /usr/lib/openssh/sftp-server

@Local Machine WinSCP

sudo /usr/lib/openssh/sftp-server

There are many workarounds to connect to an Ubuntu server as a root, using WinSCP. Here I am sharing two general options based on my experience, but consider that these configurations can vary depending on your scenario, Linux version, and more options.

Note: Take a look at a similar issue using VMware and WinSCP. Unable to Access the VCSA 6.7 via WinSCP

Reference:

WinSCP

Exit mobile version