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