React Native
React Native
Start SFTP Keyboard-Interactive Authentication
See more SFTP Examples
Demonstrates the Chilkat SFtp.StartKeyboardAuth method, which begins keyboard-interactive authentication. The only argument is the login name. It returns XML describing the server's prompts, which are answered with ContinueKeyboardAuth.
Background: Keyboard-interactive is the prompt-driven authentication method: rather than assuming a single password, the server sends one or more questions — a password, a one-time code, a security question — and the client answers each. This is how SFTP supports two-factor and other challenge-response schemes. The returned XML tells you exactly what to ask and whether to mask the input.
Chilkat React Native Downloads
import { SFtp } from '@chilkat/react-native'
async function chilkatExample() {
// Demonstrates the SFtp.StartKeyboardAuth method, which begins keyboard-interactive
// authentication. The only argument is the login name. It returns XML describing the server's
// prompts, which are answered with ContinueKeyboardAuth.
const sftp = new SFtp();
// Step 1: Connect the SSH transport. Port 22 is the usual port.
const port = 22;
try {
await sftp.connectAsync('sftp.example.com', port);
} catch {
console.log(sftp.lastErrorText);
return;
}
// Begin keyboard-interactive authentication. The returned XML describes the server's prompts.
let infoRequestXml: string;
try {
infoRequestXml = await sftp.startKeyboardAuthAsync('mySshLogin');
} catch {
console.log(sftp.lastErrorText);
return;
}
console.log(infoRequestXml);
// Answer the prompt(s) with ContinueKeyboardAuth, then call InitializeSftp.
sftp.disconnect();
}