"multer-sftp":在远程 sftp 服务器上写入时权限被拒绝



我正在使用multer-sftp进行安全的文件上传。但是当我试图写(上传)文件到服务器,我得到奇怪的错误。有人能帮我解决这个问题吗?我使用"multer-sftp": "^1.1.1","ssh2-sftp-client": "^7.1.0""express": "^4.17.1"

日志

您必须配置用户和组https://www.thegeekstuff.com/2012/03/chroot-sftp-setup/

在ssh2-sftp-client的配置中使用

let commonOpts {
host: 'localhost', // string Hostname or IP of server.
port: 22, // Port number of the server.
forceIPv4: false, // boolean (optional) Only connect via IPv4 address
forceIPv6: false, // boolean (optional) Only connect via IPv6 address
username: 'donald', // string Username for authentication.
password: 'borsch', // string Password for password-based user authentication
agent: process.env.SSH_AGENT, // string - Path to ssh-agent's UNIX socket
privateKey: fs.readFileSync('/path/to/key'), // Buffer or string that contains
passphrase: 'a pass phrase', // string - For an encrypted private key
readyTimeout: 20000, // integer How long (in ms) to wait for the SSH handshake
strictVendor: true // boolean - Performs a strict server vendor check
debug: myDebug // function - Set this to a function that receives a single
// string argument to get detailed (local) debug information.
retries: 2 // integer. Number of times to retry connecting
retry_factor: 2 // integer. Time factor used to calculate time between retries
retry_minTimeout: 2000 // integer. Minimum timeout between attempts
};