How to connect google cloud shell to termux app using ssh? - shell

I am using google-cloud-shell which is basically a shell that allows us to use online cloud shell (for developing apps etc.) and provides 5gb of free storage (only for home directory).
It is a very cool thing because i don't have PC but google-cloud-shell allows me to run gradle, java, python, etc. without any issues except one issue and i.e typing response. Although it is a very good platform for learning coding but typing is insane.
If i type a character it takes about a second to be displayed on screen and it really really sucks. Now what i want is to connect this shell to termux (which is an app just like terminal in linux) with ssh or any other thing that can connect it.
NOTE: I am not using paid version of google-cloud-storage I am just using it cloud shell which is free to use.

You can use the following gcloud command to SSH into your cloud-shell from local terminal.
gcloud alpha cloud-shell ssh
You can find more details here

Related

How is using WSL bash in vscode through the remote WSL extension different from using it by selecting as default shell while in windows?

Before I knew about the remote WSL extension for vscode, I had been using bash in it by selecting it as the default shell from the terminal option. What is the advantage of using remote WSL if all I wanted was to just use bash as the default terminal?
Hi Rohan and welcome to SO!
I'll have a shot at answering this, though someone more knowledgeable might have better insight.
When you load VSCode in windows, it accesses your various PC resources as windows resources. For example your files will be from the windows folder structure. Even if you use WSL bash as your terminal, VSCode is still acting on a windows basis.
If you use the remote WSL extension, it leverages VSCodes separation of UI and Backend by remotely starting a VSCode backend in the WSL layer, and connecting the windows UI to that backend ('remotely' although on the same PC). Due to running the backend in a linux environment, the files are loaded as linux files and handled via the WSL system, rather than normal windows access.
With regard to the question 'What is the advantage?' I would suggest the advantage is that now instead of having a split between VSCode in windows and command line in WSL, you now have both acting in harmony through WSL. It should provide some benefits (especially when WSL2 hits properly and performance increases) around things not messing in a windows manner on files you are trying to use in a linux way, and just make things feel a bit more connected.
However if you're using WSL bash just as a command line replacement and not using it for it's linux goodness (though I don't know if this would be the case), there may be less of an advantage.
It's a stepping stone to switching to devcontainers, which are really neat.
This page might help more, but that's my understanding! https://code.visualstudio.com/docs/remote/wsl

Run Electron without GUI

I see this question has been asked but the context of that question is different and so there are no answers relavent to my use case so I'm asking a new question
I have an Electron based Web Server. It's meant for beginning web developers, students, and artists that are not used to the command line (yes that's a huge debate right there but I was scolded by the teachers at the Art and Design School at UCLA for asking their students to use the command line, hence a simple server with a GUI. Please don't debate this point. It's not the point of the question)
In any case, people using this web server sometimes want to run on port 80. On Mac (and Linux?) port 80 requires admin rights and so I'd like to escalate the server's permissions to do this.
My understanding is the easiest (only?) way to do this is to spawn another process. Since the server part of my web server is effectively written in node.js and since node.js (or at least the API) is built into Electron then it seems like the best solution would be to just re-spawn my Electron app to run only the server portion.
In other words, imagine I could run the app like
/Applications/Servez.app/Contents/MacOS/Servez --no-gui --server-only --port 80
Then I could use some spawn command on Mac like
/usr/bin/osascript -e '
do shell "/Applications/Servez.app/Contents/MacOS/Servez --no-gui --server-only --port 80" with administrator privileges
'
And macOS will ask for admin privileges before running the server.
If I can't run Electron with no GUI then I could include a copy of node.js inside the Electron package but it seems like a huge waste of space given the same functionality is already inside Electron. Or maybe there is some other solution? (some API call I can make to ask for permission to use port 80?)
Setting the environment variable ELECTRON_RUN_AS_NODE will run Electron as node so I can just set that environment variable when spawning Electron

Run a shell command through a Chrome App

I have Crouton on my Chromebook with Spotify inside an Ubuntu chroot.
I can execute Spotify inside an Ubuntu chroot as a single app window via a Crouton command.
I want to create a Chrome OS application that acts as a launcher for Spotify, Skype, etc.
In short:
My Chrome OS app should execute a shell command.
I read about NPAPI, but it says it's getting depreciated (since 2013 o.O).
If there's another way (for example executing a bash script that adds a button to the shelf that just executes another shell script to open Spotify), it would also be great.
Thx in advance :)
EDIT:
With Dart this seems to be possible. It says "access File system, USB Devices, shells and much more" with it
Looks like Native Messaging is just the thing you're looking for! However you may need to create an application that can be registered as a Native Messaging Host. This application will then in turn call the shell command/script you intend to run.

How would I create an SFTP connection if my application framework does not contain an API for it?

I am trying to connect to an SFTP server with my AIR application. It doesn't matter that it's an AIR application except that I haven't found any libraries or AIR API methods for it.
My first thought is to find a library in another language and rewrite it in ActionScript. I'd rather not do that and my lack of experience may introduce security issues.
My second thought is to call a native process or command such as sftp or sshpass or curl from my main application and pass the local and remote upload locations to it and let it do the work. The downside to this is if they don't have the command installed they have to install a separate program.
My questions are:
Are these SFTP commands available by default on both Mac and Windows?
Should I store the users login (I do not want to) or prompt them to enter it each time? Does SFTP / public key remove the need for that?
I've found two related questions here and here but some of it is over my head. They also seem to be specific to *nux (which may work for Mac as well but not Windows).
I do not have the experience in this area so I would welcome those with experience to give guidance if this is a good idea or not. Overview type answers are welcome for me as I can attempt to work out the details. If no answer is given, once I've figured it out I'll post an answer. Please do not close this question (rather suggest edits).
FYI I'm using AIR to make a native process call.
An AIR application in the extended desktop profile can execute a file,
as if it were invoked by the command line. It can communicate with the
standard streams of the native process. Standard streams include the
standard input stream (stdin), the output stream (stdout), the
standard error stream (stderr).
I can also create and call a scpt, sh or bat file.
Commands installed on my Mac:
curl_init(), curl_setopt()
ssh
sftp
Commands not installed on my Mac:
sshpass
Are these SFTP commands available by default on both Mac and Windows?
No. There is no sftp nor ssh on windows by default, unless you install it through cygwin or bundle them in your application (also solution).
Should I store the users login (I do not want to) or prompt them to enter it each time?
Prompt is preferred.
Does SFTP / public key remove the need for that?
Yes, but you will have to store private key, which is almost the same like storing password.

How to spawn Linux process from Windows application?

My interactive 32-bit Windows app (now moving from Delphi [Ent] 2007 to 2009) uses command-line interactions to spawn child processes that do computationally-intensive tasks, which in turn write text files that the GUI parent app parses and analyzes - resulting in an interactive graphical display of the results.
I have access to a multiprocessor (multi-user) Linux cluster (via ssh), and would like to off-load the heavy lifting to that cluster. My question is how to spawn the processes in Linux from my Windows app. I can envision using secure FTP to put and get files, but not sure how to spawn the child processes in Linux.
Some leads for further reading would be fine - but code/pseudocode would be ideal. I can imagine that this may be more about Windows-Linux interaction than Delphi.
if you have access to ssh, one option is to issue commands through that.
For example:
ssh user#host ls -l ~
will in the ssh terminal show the files in the user's home directory. I'm not sure if this is what you really want. But it would likely work.
If you do this, you almost certainly want to setup SSH password less logins
However, A more ideal solution would likely be to setup a daemon on the linux boxes whose sole job is to run specific long running tasks in the background and let you fetch the results later.
You're going to have to install something on the Linux machine to run the process. You might find some kind of clustering or batch job submission API you can install and access from Windows. You might have to code a custom server. You might be able to run everything over ssh if you can drive an ssh process from Windows and if you have sshd installed on the Linux side. But my preference would be to write a webservice or simple CGI script on the Linux side designed to take your arguments and data and return the result over plain old http (or https as the case might be).
One way or another, this is going to encompass more than just coding on the Windows side.
I would download the full "putty" package.
As well as the excellent secure shell terminal, it includes PSCP to transfer files securely and PLINK to remote execute commands over SSH.
Hint: you will need to set up the full public/private key configuration for PLINK to work without an annoying password prompt. There is a useful guide http://unixwiz.net/techtips/putty-openssh.html>here.

Resources