Giter Club home page Giter Club logo

android-cli-openssh's Introduction

Android Command Line OpenSSH

Build openssh command line binaries for Android.

Upstreams:

HOWTO build

Requirements:

git clone https://github.com/shmilee/android-cli-openssh.git
cd android-cli-openssh
./ssh-build.sh <ANDROID_NDK_ROOT> <_PATH_SSH_PROGRAM> && find compiled/

_<PATH_SSH_PROGRAM> is the ssh install path. default is /system/busybox/ssh. This affects scp and sftp.

HOWTO use

Requirements:

Install

device_path_for_ssh_bin=`dirname <_PATH_SSH_PROGRAM>`
export PATH=${device_path_for_ssh_bin}:$PATH
export LD_LIBRARY_PATH=<device_path_for_ssh_lib>:$LD_LIBRARY_PATH

bin/ssh_exe     -> <_PATH_SSH_PROGRAM>
bin/scp         -> ${device_path_for_ssh_bin}/scp
bin/sftp        -> ${device_path_for_ssh_bin}/sftp
bin/sftp-server -> ${device_path_for_ssh_bin}/sftp-server
bin/sshd        -> ${device_path_for_ssh_bin}/sshd
bin/ssh-keygen  -> ${device_path_for_ssh_bin}/ssh-keygen
lib/libssh.so   -> <device_path_for_ssh_lib>/libssh.so

Command info

$ ssh 
usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-E log_file] [-e escape_char]
           [-F configfile] [-I pkcs11] [-i identity_file]
           [-L [bind_address:]port:host:hostport] [-Q protocol_feature]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-R [bind_address:]port:host:hostport] [-S ctl_path]
           [-W host:port] [-w local_tun[:remote_tun]]
           [user@]hostname [command]
$ ssh -V
OpenSSH_6.4p1, OpenSSL 1.0.1e 11 Feb 2013

sshd needs:

  • root permission
  • a host_rsa_key
  • set AuthorizedKeysFile .ssh/authorized_keys in sshd_config
  • add ssh client pub key in AuthorizedKeysFile
$ `which sshd` -h
option requires an argument -- h
OpenSSH_6.4p1, OpenSSL 1.0.1e 11 Feb 2013
usage: sshd [-46DdeiqTt] [-b bits] [-C connection_spec] [-c host_cert_file]
            [-E log_file] [-f config_file] [-g login_grace_time]
            [-h host_key_file] [-k key_gen_time] [-o option] [-p port]
            [-u len]

$ ssh-keygen -t rsa -f /sdcard/ssh_host_rsa_key #should be empty passphrase
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /sdcard/ssh_host_rsa_key.
Your public key has been saved in /sdcard/ssh_host_rsa_key.pub.
The key fingerprint is: xxxxxxxxxxxxxxxxxx
The key's randomart image is: xxxxxxxxxxxxxxxxx
$ netstat -tlp #run this to see if port 22 is already in use.
$ `which sshd` -d -f /sdcard/sshd_config -h /sdcard/ssh_host_rsa_key 

Strings

They are defined in:

  • jni/external/openssh/config.h
  • jni/external/openssh/pathnames.h

So, change them, when you have a non-rooted android.

$ strings `which ssh`|egrep '\.ssh/|/ssh_'
.ssh/config
/data/ssh/ssh_config
/data/ssh/ssh_host_key
/data/ssh/ssh_host_dsa_key
/data/ssh/ssh_host_ecdsa_key
/data/ssh/ssh_host_rsa_key
.ssh/identity
.ssh/id_rsa
.ssh/id_dsa
.ssh/id_ecdsa
/data/ssh/ssh_known_hosts
/data/ssh/ssh_known_hosts2
/data/.ssh/known_hosts
/data/.ssh/known_hosts2

$ strings `which sshd`|egrep '\.ssh/|/ssh_'
/data/.ssh/known_hosts
/data/ssh/ssh_known_hosts
/data/ssh/ssh_host_key
/data/ssh/ssh_host_rsa_key
/data/ssh/ssh_host_dsa_key
/data/ssh/ssh_host_ecdsa_key
.ssh/authorized_keys
.ssh/authorized_keys2
%.200s/.ssh/environment
.ssh/rc
/data/.ssh/known_hosts2
/data/ssh/ssh_known_hosts2

$ strings `which scp`|grep '/system/'
/system/bin/linker
/system/busybox/ssh

$ strings `which sftp`|grep '/system/'
/system/bin/linker
/system/bin/sh
/system/busybox/ssh

android-cli-openssh's People

Contributors

shmilee avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.