How to set a SFTP server in ubuntu VM

Renoo 0 Reputation points
2023-12-19T04:52:52.37+00:00

The key can be successfully connected to SSH, but cannot be connected to SFTP.

I tried setting up a SFTP server on my ubuntu VM but it didn't work.

Can someone help me with this question?User's image

User's image

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,013 questions
{count} votes

1 answer

Sort by: Most helpful
  1. vipullag-MSFT 26,487 Reputation points Moderator
    2023-12-19T05:13:22.11+00:00

    Hello Renoo

    Welcome to Microsoft Q&A Platform, thanks for posting your query here.

    If you are able to connect to the Ubuntu VM using SSH key authentication, but not able to connect to the SFTP server using the same key, it is possible that the SFTP server is not configured to use the same SSH key for authentication.

    -Make sure that the SSH key is added to the authorized_keys file for the SFTP user. You can add the key to the file by running the following command on the Ubuntu VM :

    User's image

    This will create a new .ssh directory for the SFTP user, and open the authorized_keys file in the nano editor. You can then copy and paste the contents of your SSH public key into the file, and save and close the file.

    -Make sure that the SFTP server is configured to use the same SSH key for authentication. To do this, edit the User's image

    file on the Ubuntu VM and make sure that the following line is uncommented:
    User's image

    -Restart the SSH server and the SFTP server by running the following commands:

    sudo service ssh restart

    sudo service vsftpd restart

    Try connecting to the SFTP server again using the sftp command and the SSH key. This time, the SFTP server should be able to authenticate using the SSH key.

    If you still encounter issues, you can check the SFTP server logs on the Ubuntu VM to see if there are any error messages that might indicate the cause of the problem. You can view the logs by running the following command:
    User's image

    This will show you the last few lines of the SFTP server log in real-time.

    Hope this helps.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.