0

(First, just want to say I'm kind of a beginner in this topic.  Secondly, I'm posting this question in this forum after days of looking for some solution and other related questions with no result. I have not been able to find any code that works for me.)

So I have two Raspberry Pi with ubuntu in both. They will have no internet connection in the final application . I need to access the #1st Pi from the #2nd Pi to run some Python programs. I've found it is possible via SSH. 

The problem I'm facing right now is that the #2nd Pi has some buttons connected. What I want is that pressing the external button in the #2nd Pi is reflected on the #1st Pi terminal. (I expect to have two terminals in my screen: the one from the 2nd Pi (main Desktop), and also the ssh terminal from the #1st Pi)

Is it possible to actually do this with no internet connection? I've found some commands using echo and some post using the "tty" system but with no prior knowledge I don't know if they fit my needs. 

I hope I find some advice here. Thank you very much to anyone that replies. 

0

SSH is only transferring the keyboard input and screen output between local and remote machine. Nothing else.

What you can do to have buttons from Pi#2 influence Pi#1 depends on what these buttons do.

If these buttons are just typing something on the keyboard, then, when you connect via ssh from Pi#2 to Pi#1 (and have terminal with that connection active while pressing the buttons), they will actually "type" on Pi#1.

If the pressing of a button runs some command on Pi#2 (let's say pressing of a button causes /home/user/myscript.py to run) then, if you have the same script on Pi#1 and want to run it too, you need to reconfigure your button so that it runs two commands instead of one:

/home/user/myscript.py
ssh pi_1 /home/user/myscript.py

The first command will run the script on your local computer (that is, Pi#2), the second command will connect to Pi#1 over ssh and tell it to run the script there. For this to work, you must have configured key-based ssh authentication between Pi#2 and Pi#1 so that ssh doesn't ask for password.

If there is some application that directly responds to pressing of a button, you have to rewrite that application so that it uses something like RPC to directly communicate with application running on another Pi and call appropriate procedures/functions there. That has nothing to do with ssh.

As for Internet connection, if you only want to communicate between those two machines, you don't need an Internet connection. However, you must properly assign IP addresses to both machines and it is recommended to put their hostnames and IP addresses into /etc/hosts file to avoid long delays upon setting up a connection caused by failing DNS lookup (or you can disable the DNS lookup altogether).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.