Raspberry pi interfacing with windows PC - raspberry-pi

Hello Friends,
I have a raspberry pi powered with Raspbian OS. I want to create a device which will perform some action like "open calculator ,open notepad,etc" on windows pc by commanding from a raspberry pi. So my problem is how to establish communication between raspberry pi and another windows pc ?
If i use VNC and SSH service, can i invoke other programs remotely on pc ?

You could use netcat, also known as nc which is included in most Linux distros and is available for Windows.
All you would do on the Windows box is get your IP address with:
ipconfig
Then you would start listening on some random port, say 5000 because that has no security restrictions and pass whatever arrives on that port to CMD.EXE for execution:
nc -l -p 5000 -e CMD.EXE
Then, on your Raspberry Pi, you would just do:
nc <WINDOWS_IP_ADDRESS> 5000
Now you can type Windows commands in your Rasperry Pi terminal for execution on the Windows box:
DIR
NOTEPAD
There is a "cheatsheet" here and I am using the technique in the section entitled "Backdoor Shells".
Note that this is a big security hole, but if it is just for yourself playing around on a private network, it is nice and simple.

Related

Configure raspberry pi wifi by writing to micro SD card

I have a raspberry pi but no external keyboard, mouse or ethernet cable to set it up - but I do have micro-sd card reader. Is there a way for me to just write my wireless internet config straight to the micro-sd card so the raspberry pi will be able to connect to the wifi, and then allow me to ssh in?
The micro-sd card already has Raspbian installed on it.
Sure.
Put the card in a drive and mount it.
Go to the partition called boot.
Create an empty file called ssh just using:
touch ssh # Works in Linux/macOS
type NUL >> ssh # Works in Windows
Create a file called wpa_supplicant.conf with your WiFi settings - be very sure that Windows hasn't added any .txt extension:
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="NETWORK-NAME"
psk="NETWORK-PASSWORD"
}
Once it works, and you can ssh successfully into the Raspberry Pi, be sure to run:
sudo raspi-config
and permanently enable ssh for subsequent reboots.

How to remote raspberry pi from putty in Rpi's console mode?

Anyone know how to remote to Raspberry Pi 3 console mode from laptop with putty ?
I can remote successfully in Rpi's desktop mode but in console mode I can't.
Assuming you are running Raspbian, SSH is disabled by default, so you must create an empty file named 'ssh' on the SD-card.
You can also
sudo raspberry-config
To enable it through your VNC connection

Raspberry Pi VNC fail connection

I face a problem that I can ping to correct IP address, it have no loss. And also I use nmap ping the pi address, and I get it correctly. Then I using VNC viewer to try access to pi, but it always show up "The connection was refused by the host computer"
Did u all have any idea ?
Your problem indicates that your Raspberry Pi was reached by the connection attempt, but that no service was running on the relevant port and hence the connection was refused. I think, this is because the VNC service is not running on your Raspberry Pi.
Update 1
Raspbian now comes with the server by default thanks to a partnership with RealVNC, it just needs to be enabled.
Original
You must enable VNC Server on your Raspberry Pi using terminal
sudo apt-get update
sudo apt-get install realvnc-vnc-server
or you can also enable VNC Server on the command line using the sudo raspi-config command.
Advanced Options->VNC:Yes
Now you can connect to the VNC Server using a application such as VNC Viewer.
I have been having this issue with my Raspberry Pi Zero W even though it worked perfectly beforehand. This page https://www.realvnc.com/en/connect/docs/raspberry-pi.html should help.
I ran vncserver in a ssh window after verifying the interface settings in raspi-config.
It started the VNC Server and gave me the VNC Server catchphrase and the IP address with Port Number as shown in the photo linked below.
vncserver output
After running that command I was able to get the VNC Viewer on my windows machine to connect to the pi.
I then ran sudo systemctl enable vncserver-x11-serviced.service in the ssh window so that it would start automatically on subsequent reboots.
I've had this same problem but found a different reason. I found three ways to get around this error message.
Plug a mouse or keyboard into the Raspberry Pi zero, waking up the screen and the VNC connection.
Wait about 5 - 10 minutes which is the amount of time for the screen saver to kick in which seems to wake up VNC connection. but don't wait to long other wise run this command to get things going via ssh "systemctl start vncserver-x11-serviced.service".
I am hoping the new update they just published will fix this problem. I don't see this as much with the Raspi B3+ as with the Zero H.
The last was plug in both monitor and mouse and that for sure fixes the VNC issues but defeats the headless connection. It seems that running headless and the screen/saver are somehow related but just not smart enough to figure it out.
For people using newer version of Raspberry, VNC option is found under:
Config>Interface Options
pinging to any service will only tells us that whether the server is currently listening on that port or not. It will not tell you the possible result to connection request asked by client.
It seems that, you have installed VNC server but not started it properly. Use this command to start it...
# vncserver start
Also recheck the port number is correct or not.
With the Rasp Pi 4 - had connecting fail after rebooting both the server and client (both Rasp Pi 4s).
Took a while to realize that I have two clients: One named "VNC Client", the other "VNC Viewer for Google Chrome".
The former works, the latter doesn't.

How can I get connection with Raspberry without access of its shell?

There are Raspberry Pi 3 model B and MicroSD with NOOBS OS. Unfortunately I have not any display to get a direct access to NOOBS shell. So remote connection could be set via ssh. However my device does not have any IP-address. I read everywhere that the connection options must be set... via shell. But it's impossible for me!
How can I resolve this problem and get remote access to shell (or to desktop even)?
I ran into this a while ago, I started using PiBakery. It will write raspbian to the SD card and add a startup script to connect to the network and enable ssh. This way the first time you boot it up, its ready to go and you can connect via SSH.
When you set it up, it also allows you to set a static IP address so you know exactly where it is when it boots.
Enable SSH by placing a file named 'ssh', without any extension, onto the boot partition of the SD card.
Connect your device to your LAN using a wired connection.
From another computer on the network execute arp -a to view locally connected hosts and get your raspberry pi's IP address.
From there you should be able to SSH into your pi.

Raspberry pi 2 .start wifi on boot

i have just bought a raspberry pi 2 . i manged to set up a headless setup by setting up an ip in the commandline.txt file and then connect to it via putty.
In the /etc/network/interfaces i set up a static ip for the wifi connection along with the connection name and password. and the wifi works fine...
But the problem is the raspberry pi wont connect to wifi unless i connect the ethernet cable and make one ssh connection using putty..
If i boot using wifi only the green light will not turn up and i am not sure if the raspberry is booting or no...but when the ethernet is connected the gren light starts blinking and i can make an ssh connection.
can anyone help me with this.
I've dealt with a lot of pi wifi issues.
Adding "auto wlan0" to /etc/network/interfaces helped, but there were still instances where it didn't start up. I have the edimax ew-7811un usb wifi adapter. Can't remember where I took this script from to give credit.
I have cron running this script (wifi_check.sh) every five minutes:
keepalive_host='ip to ping here'
ping -q -c1 $keepalive_host >> /dev/null
if [ "$?" -ne "0" ]; then
ifdown wlan0
rmmod 8192cu
modprobe 8192cu
ifup wlan0
fi
You could repurpose the script and have something like this in crontab
#reboot /bin/sleep 30 ; /path/to/wifi_check.sh
Which should wait 30 seconds after boot, try to ping the server you specify, if it can: do nothing, if it can't: bring the wifi connection down and then try to bring it back up. I don't think the lines with 8192cu in them are necessary for your purposes unless that driver is also used by your wifi adapter.