Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android port #32

Closed
keithw opened this issue Feb 28, 2012 · 48 comments
Closed

Android port #32

keithw opened this issue Feb 28, 2012 · 48 comments
Labels

Comments

@keithw
Copy link
Member

keithw commented Feb 28, 2012

It would be wonderful to have persistent remote-terminal sessions from an Android device. Theoretically the Mosh code should be compilable on Android and should be runnable from an existing GUI terminal emulator without needing to jailbreak.

@kmcallister
Copy link
Contributor

I've made some progress on this. We can now build mosh-client using the standard Android native-code tools in a relatively painless way. There's some documentation on my android branch.

When I run this mosh-client in the Android emulator (and point it at appropriate terminfo files) it runs as far as

assertion "s_height > 0" failed: file "terminalframebuffer.cc", line 52,
function "Terminal::Framebuffer::Framebuffer(int, int)"

I'll investigate this next.

@keithw
Copy link
Member Author

keithw commented Mar 19, 2012

That's fantastic! My guess is that your ioctl( STDIN_FILENO, TIOCGWINSZ, &window_size ) is somehow not getting a reasonable window size, perhaps because Android doesn't support that ioctl on ptys or the terminal emulator didn't set it?

@bvenable
Copy link

I was able to get past the s_height error by using stty to set rows and columns on the terminal.

I can set MOSH_KEY and connect by IP and it seems to work pretty well!

Now I just need to get IO::Pty installed on my non-rooted device. I got perl on there but CPAN needs File::Spec::Unix

Any thoughts? Did I just duplicate work you already did quietly?

@kmcallister
Copy link
Contributor

That's great news! You didn't duplicate any work as far as I know.

We have a pull request in the pipeline to replace that mosh Perl script with a C++ program.

@bvenable
Copy link

Cool. Note that this was via adb, I'm working on duplicating it in Terminal Emulator now.

@bvenable
Copy link

OK, stty isn't required in Terminal Emulator (https://play.google.com/store/apps/details?id=jackpal.androidterm)

I wrote a wrapper script in bash since I couldn't be bothered to get perl working. As a prereq you'll need kbox (http://kevinboone.net/android_nonroot.html) or some equivalent set of utilities. CyanogenMod should come with everything needed.

Here's the script:

MOSH_HOST=$(echo $1 | cut -f2 -d@)
ssh -t $1 "LANG=en_US.UTF8 mosh-server" > /data/local/tmp/moshserver.out
export MOSH_KEY=$(fgrep MOSH /data/local/tmp/moshserver.out | awk '{print $4}')
export MOSH_PORT=$(fgrep MOSH /data/local/tmp/moshserver.out | awk '{print $3}')
/data/local/bin/mosh-client $MOSH_HOST $MOSH_PORT

Note that you'll need to install mosh-client in /data/local/bin/ (or change the script). The syntax is "mosh user@ip". On stock ROMs you'll have to use the IP, AFAIK, but on CM7 you should have DNS in the shell.

Really all the hard work was your doing, I just kludged the last little bit, as I usually do ;-)

@bvenable
Copy link

Oh, and in case you were wondering: I switched back and forth between wifi and mobile data on my phone and the connection didn't drop! Huzzah!

@bvenable
Copy link

BTW I was running kbox_shell first and then running my mosh script, but if you don't want to do that (e.g. you're running cyanogenmod and don't need/want kbox, or you installed kbox but you want to skip the step of running kbox_shell first) you just need to add to the top of the script:

export TERM=linux
export TERMINFO=/path/to/terminfo

the terminfo file that comes with kbox is in $KBOX/etc/terminfo, e.g. if you install kbox in /data/local/kbox like I did, you'll add the following to the top of the script:

export TERM=linux
export TERMINFO=/data/local/kbox/etc/terminfo

then you can just run terminal emulator or btep and run "mosh user@ip" directly from the default command prompt

@bvenable
Copy link

@keithw @kmcallister So what's next? Fork ConnectBot and/or IRSSI ConnectBot?

BTW I did manage to get a crash out of it running irssi on a remote Linux host, with mosh running under BTEP, while I was stress testing it. I'll keep at it and see if I can reproduce it reliably, and post the error either here or as a new issue.

@keithw
Copy link
Member Author

keithw commented Apr 13, 2012

Sure, I think forking ConnectBot is the way to go, but somebody who actually knows about Android development is probably more qualified to make that call. We should give the ConnectBot folks a courtesy heads-up. It looks to be Apache 2 so I think that will work. Excited to see so much (rapid!) progress on this!

@Xorlev
Copy link

Xorlev commented Apr 16, 2012

I'm sure the ConnectBot folks would be pretty happy about getting some added capability. What route would you want to go? Boot ConnectBot and run mosh locally? Or use mosh as a library through JNI method calls?

@keithw
Copy link
Member Author

keithw commented Apr 16, 2012

Ideally we would be more tightly integrated (e.g. JNI method calls), because we would like to do things like freeze the STMClient state when the process is expelled and restore it (and reinitialize the UDP socket, perhaps from a different port number) when the user reloads us, with the connection intact.

@mlevin2
Copy link

mlevin2 commented Apr 17, 2012

I'm trying to compile based on the instructions at https://github.com/kmcallister/mosh/blob/android/android/README.md. Building on Ubuntu 10.10 x64. Getting the following error. Any suggestions?

cd Ada95 && make DESTDIR="" install
make[1]: Entering directory `/home/mlevin/mosh/android/libs/ncurses-5.9/Ada95'
for d in gen src; do \
        (cd $d ; make  install) ;\
    done
make[2]: Entering directory `/home/mlevin/mosh/android/libs/ncurses-5.9/Ada95/gen'
/usr/bin/install -c adacurses-config /home/mlevin/mosh/android/prefix/bin/adacurses-config
make[2]: Leaving directory `/home/mlevin/mosh/android/libs/ncurses-5.9/Ada95/gen'
make[2]: Entering directory `/home/mlevin/mosh/android/libs/ncurses-5.9/Ada95/src'
gnatmake -P./library.gpr -XBUILD_DIR=`cd ..;pwd` -XSOURCE_DIR=`cd ..;pwd` -XSOURCE_DIR2=`cd .;pwd` -XLIB_NAME=AdaCurses -XSONAME=libAdaCurses.so.1 -XLIB_KIND=static
gcc-4.4 -c -g -O2 -gnatafno -gnatVa -gnatwa -I- -gnatA /home/mlevin/mosh/android/libs/ncurses-5.9/Ada95/src/terminal_interface-curses-termcap.adb
terminal_interface-curses-termcap.adb:43:06: file "terminal_interface-curses.ads" not found
terminal_interface-curses-termcap.ads:42:34: file "terminal_interface-curses.ads" not found
terminal_interface-curses-termcap.ads:42:34: "Terminal_Interface.Curses.Termcap (body)" depends on "Terminal_Interface.Curses.Termcap (spec)"
terminal_interface-curses-termcap.ads:42:34: "Terminal_Interface.Curses.Termcap (spec)" depends on "Terminal_Interface.Curses (spec)"
gnatmake: "/home/mlevin/mosh/android/libs/ncurses-5.9/Ada95/src/terminal_interface-curses-termcap.adb" compilation error
make[2]: *** [../lib/libAdaCurses.a] Error 4
make[2]: Leaving directory `/home/mlevin/mosh/android/libs/ncurses-5.9/Ada95/src'
make[1]: *** [install] Error 2
make[1]: Leaving directory `/home/mlevin/mosh/android/libs/ncurses-5.9/Ada95'
make: *** [install] Error 2

@kmcallister
Copy link
Contributor

It's trying to build the ncurses library for Ada. o_O

Should be easy enough to disable that; let me look into it.

@kmcallister
Copy link
Contributor

@mlevin2: I updated the branch; does this fix your problem?

@mlevin2
Copy link

mlevin2 commented Apr 18, 2012

Much closer this time! It built fine but is having trouble on the install.

configure: creating ./config.status
config.status: creating Makefile
config.status: creating scripts/gtest-config
config.status: creating build-aux/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
+ make install
Making install in .
make[1]: Entering directory `/home/mlevin/mosh/android/libs/protobuf-2.4.1'
make[2]: Entering directory `/home/mlevin/mosh/android/libs/protobuf-2.4.1'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/home/mlevin/mosh/android/prefix/lib/pkgconfig" || /bin/mkdir -p "/home/mlevin/mosh/android/prefix/lib/pkgconfig"
 /usr/bin/install -c -m 644 protobuf.pc protobuf-lite.pc '/home/mlevin/mosh/android/prefix/lib/pkgconfig'
make[2]: Leaving directory `/home/mlevin/mosh/android/libs/protobuf-2.4.1'
make[1]: Leaving directory `/home/mlevin/mosh/android/libs/protobuf-2.4.1'
Making install in src
make[1]: Entering directory `/home/mlevin/mosh/android/libs/protobuf-2.4.1/src'
/usr/bin/protoc -I. --cpp_out=. google/protobuf/unittest.proto google/protobuf/unittest_empty.proto google/protobuf/unittest_import.proto google/protobuf/unittest_mset.proto google/protobuf/unittest_optimize_for.proto google/protobuf/unittest_embed_optimize_for.proto google/protobuf/unittest_custom_options.proto google/protobuf/unittest_lite.proto google/protobuf/unittest_import_lite.proto google/protobuf/unittest_lite_imports_nonlite.proto google/protobuf/unittest_no_generic_services.proto google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto
google/protobuf/unittest_custom_options.proto:328:20: Expected option value.
make[1]: *** [unittest_proto_middleman] Error 1
make[1]: Leaving directory `/home/mlevin/mosh/android/libs/protobuf-2.4.1/src'
make: *** [install-recursive] Error 1

@kmcallister
Copy link
Contributor

Oh, well, my primitive script android/build doesn't support make install. Just copy the mosh-client binary out of src/frontend/.

@mlevin2
Copy link

mlevin2 commented Apr 19, 2012

Yeah, looks like it never got built. After the build script ends, no binary.

make: *** [install-recursive] Error 1
mlevin@H012886:~/mosh/android$ find .. -iname '*mosh-client*'
../man/mosh-client.1
../src/frontend/mosh-client.cc
mlevin@H012886:~/mosh/android$ file ../src/frontend/mosh-client.cc 
../src/frontend/mosh-client.cc: ASCII C program text
mlevin@H012886:~/mosh/android$ 

Full output of the build script is at http://dl.dropbox.com/u/570859/mosh-build.txt

@kmcallister
Copy link
Contributor

Oh, I see, the failure is in protobuf's make install. It tries to compile some .proto files as part of the test suite, and chokes. Maybe your protoc is too old; what's the output of

$ /usr/bin/protoc --version

Anyway, we don't really need to run the protobuf test suite. Perhaps there's a way to stub it out.

@mlevin2
Copy link

mlevin2 commented Apr 19, 2012

I have 2.3.0.

mlevin@H012886:~$ /usr/bin/protoc --version
libprotoc 2.3.0

But isn't the script downloading a newer one (2.4.1)? Shouldn't it be using that one instead?

@kmcallister
Copy link
Contributor

The protobuf build runs some tests, which invoke the protoc compiler (I'm not sure exactly why, or what they're testing.) We can't use the protoc we just built, because it's cross-compiled for ARM. We could build protobuf twice, but I think disabling tests is an easier solution.

@saurik
Copy link
Contributor

saurik commented Apr 20, 2012

@kmcallister The build script I'm using for protobuf in Telesphoreo (an entirely cross-compiled ARM distribution for iOS) is as follows, which demonstrates how to easily bypass the protoc test suite with the stock distribution of protobuf (the pkg:* stuff is fairly boring boilerplate; the trick is in what is being passed to what makefile):

pkg:setup
pkg:configure
cd src
make all-am
make install-am DESTDIR="${PKG_DEST}"

@mythmon
Copy link

mythmon commented May 2, 2012

If this ends up being a fork of connect bot, it would be very nice for me if it also integrated the changes in this fork of connectbot, which adds support for the keyboard dock on the Asus Transformer.

@gw0
Copy link

gw0 commented Jun 17, 2012

What about the VX ConnectBot fork that adds remote file copying capabilities (via SCP)?
https://github.com/vx/connectbot

@kmcallister
Copy link
Contributor

Why is ConnectBot fragmented into all of these forks? Is there an upstream developer who will eventually merge these enhancements?

@ticky
Copy link

ticky commented Jun 18, 2012

@kmcallister Because the main developers haven't updated their source at all since December 2011. The original project seems to be dead.

@mythmon Why does the keyboard dock require extra work? Doesn't it just hook into the normal Android input methods?

@gw0
Copy link

gw0 commented Jun 18, 2012

@kmcallister, @ticky It is even worse with the officially released binary on Android Market, that is still from October 2010...

@mythmon VX ConnectBot has a more intuitive way of switching keymap customizations to more suite certain devices, but no Asus Transformer support yet.

@ddrown
Copy link

ddrown commented Jun 27, 2012

I took kmcallister's android changes, the c++ replacement for the perl mosh script, and combined them with my mosh ipv6 branch and created a binary package.

My android branch: https://github.com/ddrown/mosh/tree/android

mosh binary, install via opkg-cl: http://dan.drown.org/android/

This binary is suitable for running under "adb shell" or "Android Terminal Emulator" (jackpal.androidterm)

@jameslporter
Copy link

Where are we at on this? Anywhere close enough to package up and put in play?

@keithw
Copy link
Member Author

keithw commented Jul 19, 2012

ddrown has a (beta) Android APK up here: http://dan.drown.org/android/mosh/

I'm sure he would love more testers!

@m3adow
Copy link

m3adow commented Jul 20, 2012

Im useing ddrowns binary via opkg-cl, works like a charm. Will try the apk as soon as setting a port is possible.

@jameslporter
Copy link

Worked great on my S3 w/ ICS! Although I wish it were based on vx connectbot, it fixes a lot of nuances that irssi connectbot has.

@kiranos
Copy link

kiranos commented Aug 4, 2012

I would hope for vx connectbot aswell, I use it for the physical qwerty keyboard fixes on Xperia Pro, The keyboard is missing for example ctrl so vx connectbot has this fixed by remapping another key. I bet a lot of users wanting to have mosh also have alot of help from vx connectbot

@jameslporter
Copy link

Get the hackers keyboard.
On Aug 4, 2012 2:19 AM, "Stefan Eriksson" <
reply@reply.github.com>
wrote:

I would hope for vx connectbot aswell, I use it for the physical qwerty
keyboard fixes on Xperia Pro, The keyboard is missing for example ctrl so
vx connectbot has this fixed by remapping another key. I bet a lot of users
wanting to have mosh also have alot of help from vx connectbot


Reply to this email directly or view it on GitHub:
#32 (comment)

@kiranos
Copy link

kiranos commented Aug 4, 2012

It doesnt help me with a physical keyboard right? isnt hackers keyboard virtual? or am I missing something?

@lizsugar
Copy link

lizsugar commented Aug 4, 2012

You are not, @kiranos, "Hacker's Keyboard" is a virtual keyboard and really of no use to your specific request.

@gw0
Copy link

gw0 commented Aug 6, 2012

@kiranos VX ConnectBot also displays an on-screen Ctrl key if you tap on the left side.

@bpostlethwaite
Copy link

I have been working with ddrown's binary inside android term emulator but am having problems with the UTF-8 locale. Setting the default UTF-8 preference inside Android term doesn't help. Still get the error that the client-supplied environ is "US-ASCII." Those that have this working, any suggestions?

@sandos
Copy link

sandos commented Aug 30, 2012

Regarding this comment on the apk:

when the mosh background service is killed (example case: out of memory), it does not retain the session information and cannot reconnect without going through ssh again

I think it would be nice to persist the session so that it outlives killing the service, or even device restarts/crashes! Otoh that might mean security issues.

@ro0mquy
Copy link

ro0mquy commented Aug 31, 2012

I've got the same problem like bpostlethwaite:

Unfortunaly, the local enviroment ([no charset variables]) specifies the character set "US-ASCII",

The client-supplied environment ([no charset variables]) specifies the character set "US-ASCII".

LANG=
LC_COLLATE=
LC_TYPE="C"
LC_MESSAGE="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

@ookhoi
Copy link

ookhoi commented Sep 4, 2012

ddrown, your http://dan.drown.org/android/mosh/ works perfectly on my panasonic eluga. very nice, thank you!

@seagoj
Copy link

seagoj commented Sep 11, 2012

Just wanting to say a mosh fork of connect bot would be very handy indeed. I've never done any android development, but I'd be happy to do some testing on my Galaxy SII.

@mmatuska
Copy link

mmatuska commented Jan 7, 2013

To say the truth, a java client library would be the best way to go for Android & co.

@ibrahima
Copy link

ibrahima commented Aug 4, 2013

JuiceSSH beta supports mosh, for those who are interested - see https://plus.google.com/117449819357635567610 . It's also a very good SSH client, IMHO better than anything else previously available on Android. Have not tried the mosh support yet myself as I'm just trying out mosh for the first time right now, but saw this ticket on the site and figured some people might want to know.

@phedders
Copy link

It would be great to get Keiths mosh patch for ConnectBot into VXConnectbot (http://connectbot.vx.sk/) - which seems to be the best maintained fork.

@Neo-Oli
Copy link

Neo-Oli commented Apr 21, 2016

Termux now has both a mosh-client and a mosh-server which can be installed with apt install mosh

@timoc
Copy link

timoc commented Jul 9, 2016

+1 Termux should be added alongside Juicessh on the main page.
tps://play.google.com/store/apps/details?id=com.termux

@achernya
Copy link
Collaborator

It looks like this was completed in mobile-shell/mobile-shell.github.io#39

@achernya achernya removed this from the mosh-future milestone Jan 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests