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 :
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
file on the Ubuntu VM and make sure that the following line is uncommented:
-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:
This will show you the last few lines of the SFTP server log in real-time.
Hope this helps.