Termux-packages: Package request: PowerShell Core

Created on 30 Oct 2017  路  16Comments  路  Source: termux/termux-packages

This will sadly depend on #516 but once done, should allow for pretty cool stuff like remote connection on Windows machines without Cygwin.

https://github.com/PowerShell/PowerShell/blob/master/docs/building/linux.md

I thought I'd create the package request anyway, at least to raise interest in the .Net Core package request, since I clearly don't have enough time to fill the knowledge gap required to be actually helpful :)

dotnet help wanted package request

Most helpful comment

@sdrausty it is indeed impressive, though I'm not into hacking that much. The goal of this package request is using powershell as a shell on termux, and allow remote connections (legit) on windows machines.

All 16 comments

It looks like powershells are currently available in Termux through Arch Linux PRoot. This script is designed to install Arch Linux in just a few keystrokes. Tapping this link https://sdrausty.github.io/TermuxArch/setupTermuxArch.sh will transfer setupTermuxArch.sh to your device. Simply run bash ~/storage/downloads/setupTermuxArch.sh to install Arch Linux in Termux.

screenshot_20171130-004712

To add Archstrike and Blackarch distributions that provide the powershells follow these steps. Use https://sdrausty.github.io/TermuxArch/ to install, update and configure Arch Linux on device first.

Edit your /etc/pacman.conf by adding:

[archstrike]
Server = https://mirror.archstrike.org/$arch/$repo

[blackarch]
Server = http://blackarch.org/blackarch/$repo/os/$arch

Next run pacman -Syu to update your repository listing. Then to install either distribution, run one of these commands:

pacman -S archstrike --needed
pacman -S blackarch --needed

:: There are 663 members in group archstrike: ~2G download (~6G on device)
:: There are 1602 members in group blackarch: ~5G download (~16G on device)

That's a lot of pentesting. If you don't desire this much pentesting, don't install everything.

To search only for powershells use pacman -Ss powershell. To install use pacman -S powershellname.

Enjoy 馃榾

@sdrausty that sounds too good to be true. Is it too good to be true? Does that also means .NET Core itself runs in this? I will definitely look into this as soon as I can! I'll report back here!

@sdrausty even though running arch linux on Termux is definitely pretty cool, there's no powershell builds; only powershell exploits! (and. NET Core either, which makes sense). Unless I missed something.

@christianrondeau thank you for your time and diagnostics. Evidently, what you are looking for is not present it seems. What do you think about all those exploits? This is surprising news.

@sdrausty it is indeed impressive, though I'm not into hacking that much. The goal of this package request is using powershell as a shell on termux, and allow remote connections (legit) on windows machines.

Ah man.... Was hopeful and then BLAM nothing.... I am a senior DevOps engineer that works for a major cloud company that using VMWare on the backend, so some Windows boxes... I am already utilizing Samsung Dex with Termux to do a lot of my coding, development and the one thing that would be cool would be to get PowerShell and then PowerCLI. (I rarely jump into it anyways since most of my work is all *nix) but it would really make Samsung Dex a very viable OS and also it would be great to rub it in the faces of my Windows engineer counterparts. :P

@SteveL-MSFT that sounds great, though I couldn't get it to work due to /proc/stat being unavailable on Android : https://github.com/PowerShell/PowerShell/issues/10290

This conversation should probably shouldn't be in this repo, but I invite you to comment on the linked issue if you used a working method that I'm unaware of.

Thanks for sharing!

I was able to get pwsh 7 v5 running following https://dev.to/thementor/i-run-powershell-on-android-and-so-can-you-458k
Screenshot_20191024-205434

trying to get it running in Termux now but missing something

@jrdnr can you provide more details of what issue you are hitting? the /proc/stat issue was fixed awhile back

Unfortunately my Linux foo is pretty week. Running Arch from the UserLAnd app, I was able to get 7 preview 5 going no problem. But trying to get it running in Termux on a Pixel 3a in I can't figure out what is missing. When I try to run it I get the "bash: pwsh file does not exist" error.

I tried to use ldd to find if it was missing stuff and it listed a 4 or 5 libSomething.o files. That about where I ran out of ideas

Idk why I'm getting what I'm getting...

Steps:

> wget https://github.com/PowerShell/PowerShell/releases/download/v7.0.0-preview.5/powershell-7.0.0-preview.5-linux-arm64.tar.gz
> tar -xvzf powershell-7.0.0-preview.5-linux-arm64.tar.gz
> ./pwsh
bash: ./pwsh: No such file or directory

But it's there:

> ls -l pwsh
-rwx------ 1 u0_a115 u0_a115 135944 Oct 18 17:05 pwsh

I installed strace and tried it:

strace ./pwsh

execve("./pwsh", ["./pwsh"], 0x7fe34c6090 /* 15 vars */) = -1 ENOENT (No such file or directory) strace: exec: No such file or directory +++ exited with 1 +++

Even tried the absolute path and that yielded the same result.

I installed file and ran that:

file ./pwsh

./pwsh: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=81c4cf86329191d3b6daf4e8356fd7718c582a98, stripped

And it should be the right PowerShell because:

> uname -m
aarch64

That's the same thing I ran into, my research appears to indicate it had something to do with missing "libraries" required to execute.

I then tried
$ ldd pwsh
And got

libpthread.so.0
libdl.so.2
libstdc++.so.6
libm.so.6
libgcc_s.so.1
libc.so.6
ld-linux-aarch64.so.1

But now I'm way out of my depth, runs great on Arch Linux using UserLand 炉_( 汀掳 蜏蕱 汀掳)_/炉 IDK

Are those libs all there?

@TylerLeonhardt @jrdnr It is not possible to use programs that have been compiled for a "normal" linux distro in termux. pwsh has been linked against the gnu libc (glibc), which is not compatible with android's libc (bionic) that all packages in termux have been linked against.
It works fine in chroot since those system do not use android's libc.
Only way to make pwsh work in termux is to compile the sources and target android/termux.

See also https://wiki.termux.com/wiki/Differences_from_Linux

May have to wait until .NET Core supports Android before pwsh will work successfully. A number of .NET Core CLR issues for Android still active

Was this page helpful?
0 / 5 - 0 ratings

Related issues

reggi picture reggi  路  4Comments

bbtdev picture bbtdev  路  3Comments

roalyr picture roalyr  路  3Comments

jackbrycesmith picture jackbrycesmith  路  3Comments

thurask picture thurask  路  3Comments