Giter VIP home page Giter VIP logo

ssh's Introduction

MagiskSSH

This is an SSH server running as root using the great Magisk systemless root suite. It includes binaries for arm, arm64, x86, x86_64. However, only arm64 has been tested at all. It requires Android API version 24 or higher (Android 7.0 Nougat and higher).

Included software

Installation

Download the zip file and install it via the Magisk Manager app. Once this module is available in the Magisk module repository, you can just install it from there.

Configuration

SSH keys can be put into /data/ssh/root/.ssh/authorized_keys and /data/ssh/shell/.ssh/authorized_keys using your favorite method of editing files. Note that this file must be owned by the respective user and should have 600 permissions (owner: rw, everyone else: nothing).

The sshd configuration file in /data/ssh/sshd_config can be edited as well, but please be aware that some features usually present in an OpenSSH installation may be missing. Most importantly, password login is not possible using this package.

The ssh daemon automatically starts on device boot. If this is undesired, you can create a file /data/ssh/no-autostart. It will not start the service then.

Usage

Once you have written a valid SSH public key into an authorized_keys file (see section 'Configuration' above), you can connect to the device using ssh shell@<device_ip> (unprivileged access) or ssh root@<device_ip> (privileged access), while supplying the correct private key. You will drop into a shell on the device. sftp and rsync should work as usual.

If you want to manually start/stop the sshd-service, you may do so using /data/adb/modules/ssh/opensshd.init start and /data/adb/modules/ssh/opensshd.init stop. This is usually not necessary but may be useful if you use the no-autostart file described earlier. Note that the opensshd.init script may be in a different place on your device. Magisk explicitly does not give any guarantees about the install location and is free to change it.

Uninstallation

Uninstalling the module via the Magisk Manager should also delete the /data/ssh directory. This contains the host keys for the SSH server and the home directories for the SSH users. Thus, uninstalling via the Manager should get rid of all traces of this module.

If you wish to keep the runtime data for a later reinstallation of the module, create a file /data/ssh/KEEP_ON_UNINSTALL and the uninstaller will skip this step.

Contributing

Please don't file Pull Requests against the module repository. The module building is an automated process and will overwrite any changes to the files in the module repository. Feel free to create a Merge Request against the source repository, instead.

License

GPL v3

Links

Source Code Repository

Changelog

2023-07029, v0.16
  • Adress CVE-2023-38408, even though we don't ship the affected agent.
  • Version bump.
  • OpenSSH 9.3p2
2023-03-26, v0.15
  • Version bump.
  • OpenSSL 3.1.0
  • OpenSSH 9.3p1
  • Rsync 3.2.7
  • Drop mips and mips64 support
  • Build using NDK r25c, simplify building and updating a bit
  • Shrink package (strip binaries, use stronger compression)
  • Add updateJson mechanism for updating on Magisk v24 and later (thanks tamas646)
2022-02-19, v0.14
  • Add uninstaller script (see section 'Uninstallation') (thanks cl-ement05 and osm0sis)
  • Use user handles instead of names for credits (thanks osm0sis)
  • Ensure correct home directory permissions on install (thanks nazar-pc)
  • Put temp files into /data/local/tmp instead of /tmp (thanks F-i-f)
2022-02-19, v0.13
  • Version bump.
  • OpenSSL 3.0.1
  • OpenSSH 8.8p1
  • Magisk installer v24.1
2021-04-30, v0.12
  • Version bump.
  • OpenSSL 1.1.1k
  • OpenSSH 8.6p1
  • Rsync 3.2.3
  • Magisk installer v22.1
  • Fix build repository's commit hash bleeding into rsync --version
  • Properly set library path for rsync (thanks adorkablue)
2020-07-18, v0.11
  • Version bump.
  • OpenSSL 1.1.1g
  • OpenSSH 8.3p1
  • Rsync 3.2.2
  • Magisk installer v20.4
2019-11-26, v0.10
  • Version bump.
  • OpenSSL 1.0.2t
  • OpenSSH 8.1p1
  • Magisk installer v20.1
2019-04-06, v0.9
  • Remove downloading Magisk template, directly include the installer structure instead
2019-03-23, v0.8
  • Bugfix.
  • Correctly apply permissions to bin/raw files
2019-03-16, v0.7
  • Bugfixes.
  • Avoid hardcoding MODDIR in opensshd.init
  • Use wrapper script for setting LD_LIBRARY_PATH instead of setting it in init script
2019-03-10, v0.6
  • Version bump.
  • OpenSSL 1.0.2r
2018-11-04, v0.5
  • Version bumps (except rsync).
  • Set owner and permissions for shell directory
  • OpenSSL 1.0.2p
  • OpenSSH 7.9p1
  • Magisk Module Template v17000
2018-07-16, v0.4
  • Derive paths from $MODDIR instead of hardcoding /magisk
2018-04-06, v0.3
  • Version bumps.
  • Fix sftp rename on filesystems without hardlinks (ie. FAT32)
  • OpenSSL 1.0.2o
  • OpenSSH 7.7p1
  • Rsync 3.1.3
  • Magisk Module Template v1500
2017-11-23, v0.2
  • Version bumps.
  • OpenSSL 1.0.2m
  • OpenSSH 7.6p1
  • Rsync 3.1.2
  • Magisk Module Template v1400
2017-10-03, v0.1
  • Initial release.
  • OpenSSL 1.0.2l
  • OpenSSH 7.5p1
  • Rsync 3.1.2
  • Magisk Module Template v1400

ssh's People

Contributors

d4rcm4rc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ssh's Issues

unzip

unzip error !

magisk 25.2

Permission denied (publickey,keyboard-interactive).

After installation, i generate key and rsa_id in root/authorized_keys and shell/authorized_keys. But still i can't connect SSH from remote and it said Permission denied (publickey,keyboard-interactive). Do you have any idea?

Magisk 17 - stopped working

Hello!
I believe that the module stopped working after Magisk 17.0 update.
The issue might be the removal of /magisk symlink.

C:\Users\User\Desktop\platform-tools>adb shell /sbin/.core/img/ssh/opensshd.init start
starting /magisk/ssh/usr/bin/sshd... /sbin/.core/img/ssh/opensshd.init: Error 127 starting /magisk/ssh/usr/bin/sshd... bailing.
/sbin/.core/img/ssh/opensshd.init[90]: /magisk/ssh/usr/bin/sshd: not found

All the best!

/magisk/ssh/opensshd.init start

If you are manually start/stopping the sshd-service, /opensshd.init start won't work. Running the service script will, by using /magisk/ssh/service.sh start. You will however need to give the script file execute permission. You can do this at a terminal by changing the working directory; cd /magisk/ssh , and then assigning the execute permission to the script file chmod +x service.sh. OR you can do all this on a file explorer with root access.

CANNOT LINK EXECUTABLE "rsync": library "libcrypto.so.1.1" not found

I installed it on miui 11 on a Redmi Note 8 via magisk.

I can login with ssh but when i try to use Rsync this is what i get:

#As root
:/data/ssh/root # rsync
CANNOT LINK EXECUTABLE "rsync": library "libcrypto.so.1.1" not found

#As shell
:/data/ssh/shell $ rsync
sh: rsync: not found

Any idea how to fix it ?

Releases/tags

Please consider creating releases tags in this repository

Android 5.1 failed to start ssh

shell@mx4:/ $ getprop |grep sdk
[ro.build.version.sdk]: [22]
[ro.mediatek.version.sdk]: [4]
shell@mx4:/ $ getprop |grep cpu
[ro.product.cpu.abi2]: [armeabi]
[ro.product.cpu.abi]: [armeabi-v7a]
[ro.product.cpu.abilist32]: [armeabi-v7a,armeabi]
[ro.product.cpu.abilist64]: []
[ro.product.cpu.abilist]: [armeabi-v7a,armeabi]

/data/adb/modules/ssh/opensshd.init start <
starting /data/adb/modules/ssh/usr/bin/sshd... WARNING: linker: /data/adb/modules/ssh/usr/bin/raw/sshd: unused DT entry: type 0x6ffffffe arg 0x3cc4
WARNING: linker: /data/adb/modules/ssh/usr/bin/raw/sshd: unused DT entry: type 0x6fffffff arg 0x2
WARNING: linker: Unsupported flags DT_FLAGS_1=0x9
WARNING: linker: libcrypto.so.1.1: unused DT entry: type 0x6ffffffe arg 0x3256c
WARNING: linker: libcrypto.so.1.1: unused DT entry: type 0x6fffffff arg 0x2
CANNOT LINK EXECUTABLE: cannot locate symbol "openpty" referenced by "/data/adb/modules/ssh/usr/bin/raw/sshd"...
/data/adb/modules/ssh/opensshd.init: Error 1 starting /data/adb/modules/ssh/usr/bin/sshd... bailing.

SSHd not running

Basically what the title says. I've installed the module through Magisk Manager.

Magisk version: v18.1 (18100)
Magisk Manager version: v7.0.0 (185)
SSH for Magisk version: v0.7

Furthermore if trying to start the service manually on adb shell (as root) it bails without starting:

/sbin/.magisk/img/ssh # sh opensshd.init start
opensshd.init[89]: /sbin/.magisk/img/ssh/usr/bin/ssh-keygen: can't execute: Permission denied
opensshd.init[89]: /sbin/.magisk/img/ssh/usr/bin/ssh-keygen: can't execute: Permission denied
opensshd.init[89]: /sbin/.magisk/img/ssh/usr/bin/ssh-keygen: can't execute: Permission denied
opensshd.init[89]: /sbin/.magisk/img/ssh/usr/bin/ssh-keygen: can't execute: Permission denied
starting /sbin/.magisk/img/ssh/usr/bin/sshd... opensshd.init[89]: /sbin/.magisk/img/ssh/usr/bin/sshd: can't execute: Permission denied
opensshd.init: Error 126 starting /sbin/.magisk/img/ssh/usr/bin/sshd... bailing.

SFTP > 2GB

When copying (SFTP) files of large size (> 2GB), the size of the copy file is limited to 2GB without an error message ...

Can't login - android 10

I can't login as root or shell. It works on my old phone, but not my new one with Android 10.

Placed key in both /data/ssh/root/.ssh/authorized_keys and /data/ssh/shell/.ssh/authorized_keys

chmodded both to 0600.

Is there a way to see the ssh log?

For those who can't get public key authentication working

First generate a key pair using ssh-keygen

  1. Get the public key (assuming it's named id_rsa.pub) from your computer (in $HOME/.ssh/ folder assuming you are on Linux), to your phone.

  2. Copy the contents of your public key inside your phone using root browser's text editor or any other text editor of your choice.

  3. Create a file named authorized_keys inside the /data/ssh/root/.ssh/ folder.

  4. Paste the contents of your public key into the authorized_keys file using the text editor of your choice.

  5. Copy that file into the /data/ssh/shell/.ssh/ folder if you want shell login too.

  6. Now to login into your phone using ssh, you need the private key (assuming it is named id_rsa) that was generated with your public key. Type this command onto your computer in the same folder as your private key file. ssh -i id_rsa root@[_your phone's local ip_]. You don't need to type the -i id_rsa if you private and public key file is in your computer's $HOME/.ssh/ folder.

You got yourself a perfectly functioning key with right permissions! (Unless you didn't follow the instructions correctly)

stale sshd.pid prevents start

Possibly the cause of other posts related to "sshd not running": Especially after installing updates of ssh for Magisk did sshd fail to start on next device boot. The cause has been found to be a stale /data/ssh/sshd.pid file. After deleting that file manually, sshd will run on next boot, and can alternatively be manually launched by executing opensshd.init
Path of opensshd.init doesn't match the path specified in the instructions. This may be due to Magisk hidden on my system. I find it it here: /sbin/.magisk/img/ssh/opensshd.init
My workaround for the pid problem is now to let shutdown trigger execution of rm -f /data/ssh/sshd.pid

[REMINDER] Update to the new module installer!

Just in case if you are not aware, a completely new Magisk Module Installer replaces the old Magisk module template. This new format decouples ALL installation logic from modules, and encourages developers to use the provided API for installation. This new format is ENFORCED, meaning all existing modules should upgrade ASAP, and new modules are REQUIRED to follow the rules.

Carefully read through the updated docs!

Warning: All existing modules that does not use the new module format will be automatically removed on May 1st, 2019. Module devs: upgrade your existing modules ASAP!

P.S. This issue is just a kind reminder, you can close it after reading this message :)

`/tmp` no such file or directory (on v0.14)

Gives me the following output for both shell and root:

ssh [email protected]
mktemp: Failed to create file /tmp/tmp.M1EJnqCXFr: No such file or directory
sh: can't create : No such file or directory
rm: Needs 1 argument (see "rm --help")
sh: tic: inaccessible or not found
Connection to 192.168.209.94 closed.

Unable to negotiate cyber

I have this module working perfectly on 12 atvs with android 64bits 7.1.2

Today I setup an Android 32bits 9 box and when I try to connect I get "unable to negotiate cypher" and was offered a list of old protocols. I added those old protocols to my config file but then the atv offered OTHER cyphers like ssh-rsa and ssh-dsa. No matter what cyphers I add to the client, the atv will offer others.

I don't understand how this more recent atv isn't able to negotiate a cypher like all others. My install was exactly the same.

Not starting (missing sshd user)

Hi, it seems the service is not starting:

When trying to start with ./sbin/.magisk/img/ssh/opensshd.init start I get an error message:
Privilege separation user sshd does not exist

(oneplus with lineageos 15.1)

Any idea's?

Greetimgs René

Can't log in as root directly

Module is installed, keys are in place, when I try to connect I get:

lemmy@akari:~/Work/susebuildservice/home:lemmy04/Telegram> ssh root@s8
/system/bin/sh: Permission denied
Connection to s8 closed.

ssh-ing in as the shell user works tho.

More PATHs?

How can i add more PATHs? Is there something like a .bashrc?

unable to use scp: library "libcrypto.so.1.0.0" not found

I'm trying to use scp to transfer files to my phone but all I get is this error:
CANNOT LINK EXECUTABLE "scp": CANNOT LINK EXECUTABLE "scp": library "libcrypto.so.1.0.0" not found

rsync works...

Running Magisk 18, Android 8.0.0 on a Galaxy S8+

Any ideas?

/data/ssh/shell should by CHOWNed by shell user

When I installed the module it was chowned by root. I could not log on as shell via ssh until I chowned the directory to shell. It looks like sshd was unable to read ,ssh/authorized_keys until I did so.

scp doesn't work

The scp command does not work.
It shows:
/usr/local/bin/ssh: No such file or directory
lost connection

The reason is, that scp looks for ssh and cannot find it, as the path of ssh is hardcoded in
/data/adb/modules/ssh/usr/bin/raw/scp as "/usr/local/bin/ssh"

ssh and rsync work fine.

Thank you for the module.

MODDIR problem

dear maintainer team

i have to change MODDIR path from /magisk/ssh to /sbin/.core/img/ssh in the opensshd.init file to make the script to work
#: ${MODDIR:=/magisk/ssh}
: ${MODDIR:=/sbin/.core/img/ssh}

device: xiaomi redmi note 3
magisk: 18 stable
os: mokee 7.1

thanks

if sshd is set to listen on VPN ip address, it will not launch.

if sshd is set to listen on VPN IP adress, it will not launch. probably because sshd tries to run before the vpn interface is brought up during boot by android, doesn't see the IP valid, and bails.

i'm using with wireguard, set to "always on" in android settings.

Can not run some CMDs over SSH

PixelExperience_caf_whyred-9.0
Magisk 19.2

Can not run some su CMDs over SSH shell, but over ADB everything is OK
The error gives a sign of 'Aborted'
Have been using SSH-Module for some time now, started giving this error recently

Examples:
media volume --stream 2 --set 5
input keyevent KEYCODE_HOME
input swipe 530 1962 533 1962 100
content insert --uri content://settings/system --bind name:s:show_touches --bind value:i:0

LOGCAT.txt

Server refused key?

So I installed Magisk and the ssh module on a stock firmware Galaxy S7,

I generated a private/public keypair using puttygen, pasted the public key in /data/ssh/.ssh/root/authorized_keys and used the generated private key in putty in order to connect to root@, but server keeps refusing my key.

I have used this module numerous times and suddenly, now, it doesn't work.

Any ideas?

Required Directory Permissions & Ownership.

Besides the permissions of authorized_keys, in my device it was also needed to change the permissions of the parent directories as well as their ownership for the ssh login to work.

More Specifically .ssh and root or shell (depending on which you are going to use).

So we got:

chmod 600 /data/ssh/root/.ssh/authorized_keys
chmod 600 /data/ssh/shell/.ssh/authorized_keys

chown root /data/ssh/root/.ssh/authorized_keys
chown shell /data/ssh/shell/.ssh/authorized_keys
chmod 700 /data/ssh/root/.ssh
chmod 700 /data/ssh/shell/.ssh

chown root /data/ssh/root/.ssh
chown shell /data/ssh/shell/.ssh
chmod 700 /data/ssh/root
chmod 700 /data/ssh/shell

chown root /data/ssh/root
chown shell /data/ssh/shell

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.