Connect to my droplet using filezilla?

March 7, 2017 1.1k views
Applications CentOS

I check with help connecting using filezilla and so far no luck. Currently running MacOS and filezilla running perfectly. It just dont connect?

I finally being able to setup root, and 2nd user to connect to the droplets using SSH from terminal. However not from filezilla.

Disconnected: No supported authentication methods available (server sent: publickey)

that is the error message and yes I try to include the private key along and filezilla will convert the key into ppk. However the error continue.

For connecting to my centOS do I need to install an any new apps in the server? sFTP server?

Anyone with a solution?

3 Answers

There should not be any special setup required. All droplets include an SFTP service by default (this is provided by the SSH service). I'd recommend checking out the tips here on using an ssh key with Filezilla on Mac. Make sure you select port 22 and protocol: SFTP.

@KingRichard

You'll normally receive that error when you have a valid user but the user doesn't have a file like the one below; incorrect permissions on the .ssh directory and the authorized_keys file may result in the same error.

/home/username/.ssh/authorized_keys

Your root user should be able to connect as long as your public key is in the file below and it has the proper permissions.

/root/.ssh/authorized_keys

For non-root users, you need to go a little further and setup SFTP for each one. You can do this relatively easily by following the steps I've outlined below.

I'll use myuser as the username in this example.

...

Create SFTP Group

groupadd sftpgroup

Create the Home & .ssh Directories

mkdir -p /home/myuser/.ssh

Create User & Set Home Directory

useradd -d /home/myuser -s /bin/nologin myuser

Set myusers' Password

passwd myuser

Add User to SFTP Group

This will append the user to the new SFTP Group instead of changing the users default group. That's intentional.

usermod -aG sftgroup myuser

Create the authorized_keys File

touch /home/myuser/.ssh/authorized_keys

Setup Proper Directory & File Permissions

chmod 700 /home/myuser/.ssh
chmod 644 /home/myuser/.ssh/authorized_keys
chown myuser:myuser /home/myuser/.ssh

Modify SSH Configuration

nano /etc/ssh/sshd_config

Find:

Subsystem sftp /usr/lib/openssh/sftp-server

Replace with:

Subsystem sftp internal-sftp

Below:

UsePAM yes

Add:

Match Group group-sftp-only
   ChrootDirectory %h #set the home directory
   ForceCommand internal-sftp
   X11Forwarding no
   AllowTCPForwarding no
   PasswordAuthentication yes

Now restart SSH - service ssh restart.

Adding a SSH Key for myuser

The file /home/myuser/.ssh/authorized_keys is where the public key needs to be pasted to.

nano /home/myuser/.ssh/authorized_keys

Paste in your Public Key (the key starting with ssh-rsa ....) and save the file.

Creating a Few Test Directories for myuser

mkdir -p /home/myuser/{public,private,logs}
chown -R myuser:myuser /home/myuser/*

Login to SFTP on Port 22

With all of that out of the way, you should now be able to login using SFTP on Port 22 as long as the public key is correct and the steps above have been followed.

  • I followed this to the letter but I am still receiving "Permission denied (publickey)." for the command
    ssh [usernamehere]@[ip.address] (obviously replaced with real values...) - any help?

    • I solved my problem - I was missing "ssh-rsa" from the top of my authorized_keys file.

Have another answer? Share your knowledge.