SSH and SFTP client library for React Native on iOS and Android.
A full set of documentation is available on Mintlify, which includes:
- Installation
- Quick start guide
- API reference
- Core concepts
- Guides
Below is a quick installation and usage guide to get up and running. The full documentation is recommended in addition to the below.
Warning
Host key verification is not performed. This library does not verify or pin the remote server's host key (on Android StrictHostKeyChecking is disabled, and on iOS the host key is not checked), so connections are susceptible to man-in-the-middle attacks. Until this is addressed, only connect over networks you trust. See the security guide for details.
npm install @dylankenneally/react-native-ssh-sftpUpdate your Podfile to use the aanah0's fork of NMSSH. Note that we use the forked version to give us a required later version of libssh. Your Podfile is located in your React Native project at ./ios/Podfile.
target '[your project's name]' do
pod 'NMSSH', :git => 'https://github.com/aanah0/NMSSH.git' # <-- add this line
# ... rest of your target details ...
endAnd then run pod install in your ./ios directory.
cd ios
pod install
cd -Tip
Adding a postinstall script to your package.json file to run pod install after npm install is a good idea. The pod-install package is a good way to do this.
{
"scripts": {
"postinstall": "npx pod-install",
}
}If you are using Flipper to debug your app, it will already have a copy of OpenSSL included. This can cause issues with the version of OpenSSL that NMSSH uses. You can disable flipper by removing/commenting out the flipper_configuration => flipper_config, line in your Podfile.
No additional steps are needed for Android.
This project has been updated to use React Native v84 (the latest at the time of writing, Feb 2026) - which means that manual linking is not required.
All functions that run asynchronously where we have to wait for a result returns Promises that can reject if an error occurred.
Note
On iOS, this package currently doesn't support the simulator, you will need to have your app running on a physical device. If you would like to know more about this, see this issue. I'd welcome a PR to resolve this.
import SSHClient from '@dylankenneally/react-native-ssh-sftp';
SSHClient.connectWithPassword(
"10.0.0.10",
22,
"user",
"password"
).then(client => {/*...*/});import SSHClient from 'react-native-ssh-sftp';
SSHClient.connectWithKey(
"10.0.0.10",
22,
"user",
privateKey="-----BEGIN RSA...",
passphrase
).then(client => {/*...*/});{privateKey: '-----BEGIN RSA......'}
{privateKey: '-----BEGIN RSA......', publicKey: 'ssh-rsa AAAAB3NzaC1yc2EA......'}
{privateKey: '-----BEGIN RSA......', publicKey: 'ssh-rsa AAAAB3NzaC1yc2EA......', passphrase: 'Password'}
client.disconnect();const command = 'ls -l';
client.execute(command)
.then(output => console.warn(output));- Supported ptyType: vanilla, vt100, vt102, vt220, ansi, xterm
const ptyType = 'vanilla';
client.startShell(ptyType)
.then(() => {/*...*/});client.on('Shell', (event) => {
if (event)
console.warn(event);
});const str = 'ls -l\n';
client.writeToShell(str)
.then(() => {/*...*/});client.closeShell();client.connectSFTP()
.then(() => {/*...*/});const path = '.';
client.sftpLs(path)
.then(response => console.warn(response));client.sftpMkdir('dirName')
.then(() => {/*...*/});client.sftpRename('oldName', 'newName')
.then(() => {/*...*/});client.sftpRmdir('dirName')
.then(() => {/*...*/});client.sftpRm('fileName')
.then(() => {/*...*/});client.sftpDownload('[path-to-remote-file]', '[path-to-local-directory]')
.then(downloadedFilePath => {
console.warn(downloadedFilePath);
});
// Download progress (setup before call)
client.on('DownloadProgress', (event) => {
console.warn(event);
});
// Cancel download
client.sftpCancelDownload();client.sftpUpload('[path-to-local-file]', '[path-to-remote-directory]')
.then(() => {/*...*/});
// Upload progress (setup before call)
client.on('UploadProgress', (event) => {
console.warn(event);
});
// Cancel upload
client.sftpCancelUpload();client.disconnectSFTP();You can find a very simple example app for the usage of this library here.
This package wraps the following libraries, which provide the actual SSH/SFTP functionality:
- NMSSH for iOS
- JSch for Android (from Matthias Wiedemann fork)
This package is a fork of Emmanuel Natividad's react-native-ssh-sftp package. The fork chain from there is as follows: