SSH into raspberry pi - linux

I have a question regarding SSH. For school assignments, I always write code on my mac then transfer it over on my raspberry pi to make sure it will compile correctly without errors as they are tested on the pi and sometimes when I transfer it has errors.
To avoid hassle of connecting everything to the pi, if I SSH into the pi, then compile my program from my mac, would it use the raspberry pi compiler?

If you are connected vi ssh and issuing the commands in that terminal session, yes, it's going to use the compiler on the pi.
A better option, and more educational, might be to cross-compile the code for the pi on your mac. You can leverage the much greater processing power of the desktop to significantly reduce your compile time.
Cross Compiling on Mac OSX for Raspberry Pi

Yes it would remotely access the host's OS (in your case the RPi) to perform the compilation.
Here is a guide to get you started:
https://www.modmypi.com/blog/remotely-accessing-the-raspberry-pi-via-ssh-console-mode
Also, in case you want a remote desktop connection, on your raspberry pi enter the following command:
sudo apt-get install xrdp
providing you've already updated and upgraded your package libraries ;)

Yes, If you are using ssh and writing code in that terminal session then the code will be compiled in the pi, it is the best way to do so.

Issuing command in the terminal session via SSH (laptop connected with Raspi), compilation will be done at Raspi. PuTTY is a very useful tool for this, you just need to enable SSH at Raspi and input your IP address at PuTTY only! Click to the PuTTY website http://www.putty.org/ and download it.

Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. The best-known example application is for remote login to computer systems by users.
When you connect to any remote system or server via ssh you are using the same system via command prompt. So, if you do any work via SSH the compilation will be done by the remote system.

Related

Eclipse unable to connect to remote Linux via SSH

I am trying to set-up Eclipse on Windows to build and debug a C application on an i.MX6 eval kit running Yocto Linux. When I try to connect either via the debugger or via the Remote System Explorer I get the following error:
Could not open connection.
Reason: Algorithm Negotiation fail
I can connect to the board via Tera Term using SSH and port 22, so it seems like GDB server is running, but there is some incompatibility between Eclipse SSH and Linux SSH. I've seen several posts about this, but most of them are years old, and no longer apply. I tried changing the connection settings in Eclipse, but nothing I have tried seems to work.
How do I configure Eclipse, or Yocto Linux, to allow them to communicate?

How to debug remote Python script in VS Code

I am doing Python development in Raspberry Pi. I have installed VS Code in my laptop and have installed the ssh extension. Using this I can easily connect to Raspberry Pi. While I am connected I can see that VS Code has also loaded the Python interpreter of Raspberry Pi. I can run my Python script from within the vs code but when I tried to debug the code, nothing happens.
Is it possible to remotely debug the Python script from laptop to Raspberry Pi? How can I enable this?
I have resolved this issue. If anyone wants to do remote development and debugging, follow below steps:
Install remote ssh extension in VS code
Once installed, you will find a green icon on the bottom left corner in vs code which allows us to connect to the remote machine.
Connect to the remote machine using the standard ssh command. Alternatively, you can use ssh-keygen to generate a public-private key if you don't want to use the password at every prompt.
Once you are connected to remote machine, you can open the file explorer and create any python file. When you will save this, it will get saved in your remote machine. This way you are using your machine to remotely develop code on another remote machine.
Good thing about vs code is that it selects the remote machine's python interpreter so all the packages which you have installed on your remote machine will work with IntelliSense.
In order to debug the code, we will use debugpy. Install this on both machine (remote & local)
On your remote machine, run below command:
python3 -m debugpy --listen 1.2.3.4:5678 --wait-for-client app.py
here 1.2.3.4 is the IP of remote machine. This will start a remote debugger which will wait for a clients connection.
On your local machine, in VS code open Run & Debug, add a configuration of Python: Remote Attach. Make sure that launch.json has the host as the IP of your remote machine and port as 5678.
Now start debugging as normal and you will notice the code will break at first breakpoint and from here you can proceed normally as we used to do in local debugging process.
TBH, this is best feature VS code has because most of the software allows you to do remote development which is nothing but just a normal SSH but remote debugging gives you more control. I was doing some python project on Raspberry Pi and obviously cannot install VS code or pycharm on it. But with this feature now I can easily develop the code using Pi's python interpreter and debug it as well.
If anyone is having any issues, let me know. Happy to help.

Is it possible to open X11 application in terminal of a server in linux?

I can launch X11 application through my local machine to X11 enabled server.
e.g. ssh -x from my localmachine(linux desktop) then launch a installed application from the minimal server.
I would like to know if it's possible to access my installed application directly from my minimal server. e.g. ssh -x ?
Thank you.
Not sure if it is useful but better you can use either Xming or Mobaxterm to get an X11 for a linux machine . Ultra VNC/VNC are also some of those kind .

how to run Emacs when SSH-ing from Linux to Mac OS X (with XForwarding)?

At work I get a choice of two laptops to use, Windows or Mac. Being a linux guy, I thought the MacBook Pro will be a good fit.
So I bring the MacBook Pro laptop home, and realize it doesn't have a right-ctrl key. And the bottom panel is annoying as hell. So I say, no problem, I'll sort all that out later, for now I'll use it as a server and remotely ssh into it from my crispy Xfce workstation environment. Well...
I've spent about a day trying to figure out:
How to ssh into the mac from my Fedora workstation, run emacs and have it show up (XForwarded) on my linux workstation ? You know like this:
I've installed XQuartz and changed /etc/sshd_config and /private/etc/sshd_config with:
X11Forwarding yes
XAuthLocation /opt/X11/bin/xauth
Mind you, xeyes works, and so does xclock, yay !!!
Apparently X forwarding is working okay, since other gui apps are showing up remotely. But as for Emacs, foggetaboutit.
The default Emacs from /usr/bin/emacs just runs it in -nw mode. Then I've installed the latest Emacs 24.3 (into /Applications/Emacs.app/Contents/MacOS/Emacs). This time, if I'm physically logged into the laptop (i.e. from the laptop keyboard) running Emacs from ssh shows up on the laptop's screen !!! WTF? If I logout of the laptop, then I get:
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
I'm at my wits ends. Any ideas why other X apps work? Anything special about Emacs?
The Emacs.app binary is built to use Mac OS X's window system (we call it "ns" around here), which has nothing to do with X11, so you can't forward it over the network to another host. Instead, you want to install another Emacs on your Mac, which is built to use the X11 window system (so you can use it locally via Xquartz (which lets X11 clients use the native Mac OS X display), or you can use it remotely like any other X11 client).
The easiest way is probably to built it yourself: get the emacs-24.3.tar.gz source code and compile it with ./configure --with-x; make.
With Mac Ports x11 or gtk variant has to be selected, like this:
sudo port install emacs +x11
or that:
sudo port install emacs +gtk

Xming Display is very slow when using SSH

I am using SSH and Xming to run Simics simulator and connect to some Linux guest machine. I use x11 Tunneling. The x server seems to be very slow and I need to spend a long time to run a single command on the linux guest machine. Do you have any idea what might cause the problem? Is this the problem of ssh secure shell or the xming?
Thanks.
Traffic compression might solve your problem. Use ssh -C
I'm using Putty.
Putting Blowfish compression to the top of the list in Connection/SSH/Cipher node also helped a little bit.
Compression is enabled in SSH node.

Resources