I'm trying to build a sFTP server for an application because I need to authenticate users from an existing DB and I don't want to synch them. So I've used ssh2 to do so and I mostly got it to work but when I try to connect via the SFTP (by Natizyskunk) extension in VS Code it loops forever and on the server side I get :
...
READDIR 290 <Buffer 2f 68 6f 6d 65 2f 64 65 62 69 61 6e 2f 63 6c 69 65 6e 74 46 69 6c 65 73>
READDIR 291 <Buffer 2f 68 6f 6d 65 2f 64 65 62 69 61 6e 2f 63 6c 69 65 6e 74 46 69 6c 65 73>
READDIR 292 <Buffer 2f 68 6f 6d 65 2f 64 65 62 69 61 6e 2f 63 6c 69 65 6e 74 46 69 6c 65 73>
^C
What am I doing wrong ?
Where can I find information on what exactly is needed for each actions (READDIR, OPENDIR, etc.) ?
Here is the cb for READDIR:
.on('READDIR', function (reqid, handle) {
console.log('READDIR', reqid, handle)
if (handle && openDirs[handle.toString()]) {
const path = openDirs[handle.toString()];
const dir = fs.readdirSync(path, { withFileTypes: true });
const entries = dir.map(dirent => {
const stats = fs.statSync(path + '/' + dirent.name);
return {
filename: dirent.name,
longname: `${stats.mode} ${stats.uid} ${stats.gid} ${stats.size} ${stats.mtime} ${dirent.name}`,
attrs: stats
};
});
sftp.name(reqid, entries);
} else {
sftp.status(reqid, 4);
}
})
Here's the github page for the project : https://github.com/GPharand/sFTP/blob/main/sftpServer.js (main file is sftpServer.js )
// SFTP extension Config file
{
"name": "My sFTP Server",
"host": "218.118.168.148", // Fake ip address
"protocol": "sftp",
"port": 2222,
"username": "username",
"password": "password",
"remotePath": "/home/debian/clientFiles",
"uploadOnSave": false,
"useTempFile": false,
"openSsh": false
}
Here's the github page for the project : https://github.com/GPharand/sFTP/blob/main/sftpServer.js (main file is sftpServer.js )
Thanks for you help
I'm trying to acheive a workable connection between VS code (SFTP) and my server so my user can edit their scripts on my platform.