Expand my Community achievements bar.

Getting all authentication failed

Avatar

Level 3

I am trying to connect server via sFTP and I did code that is given below--

 

 

 

 

const fetch = require('node-fetch')
const { Core } = require('@adobe/aio-sdk')
const { errorResponse, stringParameters, checkMissingRequestInputs } = require('../utils')
const sftpClient = require('ssh2-sftp-client');


// main function that will be executed by Adobe I/O Runtime
async function main(params) {
// create a Logger
const logger = Core.Logger('main', { level: params.LOG_LEVEL || 'info' })
let sftp = new sftpClient();

try {
// 'info' is the default level if not set
logger. info('Calling the main action')

// log parameters, only if params.LOG_LEVEL === 'debug'
logger.debug(stringParameters(params))

//Check for missing request input parameters and headers
const requiredParams = ['host', 'port', 'username', 'password']
const requiredHeaders = []
const errorMessage = checkMissingRequestInputs(params, requiredParams, requiredHeaders)
if (errorMessage) {
// return and log client errors
return errorResponse(400, errorMessage, logger)
}

const options = {
host: params.host,
port: params.port,
username: params.username,
password: params.password
};

sftp.connect(options).then(() => {
console.log('Connected');
return sftp.list('/');
}).then((data) => {
console.log('Then', data);
}).catch((err) => {
console.log(err, 'catch error');
 
});
 
 
even after using the right port username and password, I am getting this error
 
ShubhamAg2_0-1731676710786.png

I checked the same code with the node.js locally and it is working fine

1 Reply

Avatar

Employee
Employee

Hi @ShubhamAg2 , I'd recommend opening a support ticket through your regular channels