Screen sharing between Raspberry PI and Mac OSx [closed] - macos

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I want to use the Screen Sharing OSx built-in App to manipulate the actual X session open in my Raspberry PI.
Just to be clear I want to see in my VNC session the same image the Raspberry is sending through the HDMI. So I can move the mouse in my computer and the cursor is also moving in the Raspberry screen.
I have tried several combinations of vnc-servers and configs but neither have worked.

As I have spent several hours solving this I so answer my self in case someone needs the instructions as I would wanted to find them.
First, the most popular vnc-server (tightvncserver) is not fullfilling my specification that the X-session has to be the same in my VNC client App and in the Raspberry screen.
The vnc-server that does the work is x11vnc
Install x11vnc
sudo apt-get install x11vnc
Looks like it requires you to set up a password:
x11vnc -storepasswd
Test installation and connection
You can already start the vnc-server:
x11vnc -forever -usepw -display :0 -ultrafilexfer
Check the service is active and listening
$ sudo netstat -nlp | grep vnc
tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN 2575/x11vnc
And connect from your Mac just opening Screen Sharing and introducing the Raspberry's ip:
Make x11vnc to start on boot
Config:
# ~/.config/autostart/x11vnc.desktop
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=X11VNC
Comment=
Exec=x11vnc -forever -usepw -display :0 -ultrafilexfer
StartupNotify=false
Terminal=false
Hidden=false
Be sure there is not problems to access to this file:
sudo chmod a+r ~/.config/autostart/x11vnc.desktop
Make the Raspberry to be visible in the sharing network of the Mac
sudo apt-get install netatalk
sudo apt-get install avahi-daemon
sudo update-rc.d avahi-daemon defaults
Config:
# /etc/avahi/services/afpd.service
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_afpovertcp._tcp</type>
<port>548</port>
</service>
</service-group>
Config 2:
# /etc/avahi/services/rfb.service
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_rfb._tcp</type>
<port>5900</port>
</service>
</service-group>
Restart service:
sudo /etc/init.d/avahi-daemon restart
Finding the Raspberry from your Mac
Using Finder into the section Shared > All... should be your Raspberry. From there you can click in the button Share Screen...

I found this post useful however I had to go looking for the following information to complete my setup - hope this help someone else
Just want to clarify the you need to do the following steps:
cd ~/.config/
mkdir autostart
nano x11vnc.desktop
and then paste code listed above
then you may also want to change the resolution by setting or uncommenting, the following lines, in /boot/config.txt:
hdmi_force_hotplug=1
hdmi_group=1
hdmi_mode=16 # (or any other pi resolution you want, 16 is for 1080p) Reboot your Pi (sudo reboot)

Related

access GPSD port 2947 over network [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 months ago.
Improve this question
Have a RPI2 with latest Jessie Lite Raspbian Jan 2017 with Adafruit Ultimate GPS hat and PPS using info from a post at digitalbarbedwire.com. Easy setup and PPS and all gps commands work great locally.
I am trying to get gpsd to accept incoming requests over the network on port 2947 to export position info (OpenCPN). I edited /etc/default/gpsd to add the -G option GPSD_OPTIONS="-n -G" but external requests are not being allowed. If I stop gpsd (sudo service stop gpsd), and invoke gps in the foreground (/usr/sbin/gpsd -N -n -G /dev/ttyAMA0 /dev/pps0, all works fine! So I am guessing there is a permissions problem starting the gpsd as a daemon, but I haven't figured it out yet. Drivings me nuts!
Any suggestions?
Relevant files:
$ cat /lib/systemd/system/gpsd.socket
[Unit]
Description=GPS (Global Positioning System) Daemon Sockets
[Socket]
ListenStream=/var/run/gpsd.sock
ListenStream=[::1]:2947
ListenStream=0.0.0.1:2947
SocketMode=0600
[Install]
WantedBy=socket
$ cat /etc/default/gpsd
# Default settings for the gpsd init script and the hotplug wrapper.
# Start the gpsd daemon automatically at boot time
START_DAEMON="true"
# Use USB hotplugging to add new USB devices automatically to the daemon
USBAUTO="true"
# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
DEVICES="/dev/ttyAMA0 /dev/pps0"
# Other options you want to pass to gpsd
GPSD_OPTIONS="-n"
$ cat /lib/systemd/system/gpsd.service
[Unit]
Description=GPS (Global Positioning System) Daemon
Requires=gpsd.socket
# Needed with chrony SOCK refclock
After=chronyd.service
[Service]
EnvironmentFile=-/etc/default/gpsd
ExecStart=/usr/sbin/gpsd -N -G $GPSD_OPTIONS $DEVICES
[Install]
Also=gpsd.socket
Any ideas?
Gpsd is not actually listening on port 2947, systemd is. By default in Debian this is local only. When a request comes in systemd starts gpsd, if necessary, and redirects future requests to the daemon. So giving gpsd the -G parameter will not actually change anything.
You need to add an override for the systemd gpsd.socket unit, and tell it to listen on all addresses:
# /etc/systemd/system/gpsd.socket.d/socket.conf
[Socket]
# First blank ListenStream clears the system defaults
ListenStream=
ListenStream=2947
ListenStream=/var/run/gpsd.sock
Best practice is to put this override file in /etc/systemd/, and not to edit the unit files in /lib/systemd/.
Documentation on the systemd.socket syntax: https://www.freedesktop.org/software/systemd/man/systemd.socket.html
Linux Mint 19, I had to replace 127.0.0.1 with 0.0.0.0, then I could share GPS data on LAN
#/lib/systemd/system/gpsd.socket/gpsd.socket
[Unit]
Description=GPS (Global Positioning System) Daemon Sockets
[Socket]
ListenStream=/var/run/gpsd.sock
ListenStream=[::1]:2947
#ListenStream=127.0.0.1:2947
ListenStream=0.0.0.0:2947
SocketMode=0600
[Install]
WantedBy=sockets.target
Another way to do it is to do a terminal-less SSH session with port forwarding.
For example, let's say you have PC1 running a gpsd service (either via systemd or stand-alone).
From PC2, you can do this:
ssh -N -L 2947:localhost:2947 user#PC1
The -N flag prevents an actual terminal session (no commands executed).
The -L flag means forward port 2947 to localhost 2947.
Now, ssh will not auto-reconnect if for some reason the session is lost or terminated. The work around is to install autossh, available in most linux distro repositories.
You can then use autossh like so:
autossh -N -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -L 2947:localhost:2947 user#PC1
If it works, add -f to let autossh go in background mode.
You can easily run autossh from rc.local or a systemd unit. Doing it this ways means you only have to allow SSH port in (22) and are now passing the gps info via a secure encrypted connection, something that a gpsd socket session alone can't do. Obviously, it helps if you have a key pair setup between PC1 and PC2 as you won't need a password.
You can run on PC2 any of the gpsd tools that come with it as it will appear local to it. API calls from scripts/programs will also work as if port 2947 was actually running gpsd locally.
Look here for more detail on how to use autossh.
After running down all the suggestions including the above, I ended up just following the instructions on the troubleshooting page for gpsd in gitlab, in the last section called "Real World Example". That's the only thing that worked for me.
Install socat
and use this command:
socat TCP4-LISTEN:2948,reuseaddr,fork TCP4:localhost:2947
And use port 2948 over network
You can add this in crontab

Fedora 23 passwordless ssh key not working in automated host addition [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I have installed Fedora 23 and have tried to do a passwordless login with:
# ssh-copy-id ~/.ssh/id_dsa.pub user#host
which successfully copies the key to the host machine and I have checked in the host machine in:
# tail -n10 ~/.ssh/authorized_keys
and my PC name exists as the last line but when trying to login:
# ssh user#host
I am asked for a password! I have tried to login to Ubuntu and CentOS and get the same result. I have done this previously with multiple linux distros including Fedora 21, CentOS and Ubuntu and it works just fine.
I need this to do finish the automated host addition script which adds a host and then logs in automatically (add_user_host):
#!/bin/bash
ssh-copy-id ~/.ssh/id_dsa.pub $1#$2;
ssh $1#$2;
all you would do is run:
# add_user_host user host
Openssh-7.0 obsoleted DSA keys. To use them you need to specify PubkeyAcceptedKeyTypes +ssh-dss in your ssh_config (as mentioned in your linked thread) to make them working, or rather use other keys (RSA, ed25519).
This case has also its page on official webseite and part in release notes.

Redis start as service [unrecognized service error] [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I install redis on Ubuntu 14.04. I want to start redis as service. but I can't do that.
firstly , I cant start and stop redis server by using following commands:
sudo /etc/init.d/redis-server start
sudo /etc/init.d/redis-server stop
But I try following command to start as service , I get "redis-service: unrecognized service"
sudo service redis-service start
I wait your helps, thanks
If you've used the defaults, your Redis service is actually named redis_6379 - try the following:
sudo service redis_6379 start
try: sudo service redis-server start
I think,to configure redis as service,you need to execute below line.
sudo update-rc.d redis-server defaults
in your shell, use this command: redis-cli shutdown
or
into folder src use: ./redis-server

Postgres DB not starting on Mac OSX: ERROR says: connections on Unix domain socket [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I ve installed Postgresql and then ran a bunch of rails apps on my local Mac OSX Mountain Lion and created databases etc. Today after a while when I launched pgAdminIII and tried to launch a database server I got this error:
A quick google showed this post. More browsing pointed to the fact that there might be some sort of postmaster.pid file lying around that might be the root cause of this. If I delete that things would be fine.
However, before I go deleting stuff on my computer I wanted to make sure Im debugging this in a systematic way which would not result in more problems.
Somewhere I read that before deleting that file, I need to run this command:
ps auxw | grep post
If I get no results then, its OK to delete the file. Else not. Well, I got this result of that command:
AM 476 0.0 0.0 2423356 184 s000 R+ 9:28pm 0:00.00 grep post
So now of course Im throughly confused.
So what should I do?
Here is part of my postgres server error log:
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 171) running in data directory "/usr/local/var/postgres"?
Postgresql is still not running, still get the same error and nothing has changed. Im too chicken to delete things without checking on SO.
Could some of you experts please guide a noob.
Thanks
I had the same problem today on Mac Sierra. In Mac Sierra you can find postmaster.pid inside /Users/<user_name>/Library/Application Support/Postgres/var-9.6. Delete postmaster.pid and problem will be fixed.
This can happen if the database did not shut down correctly. To fix it simply delete the postmaster.pid file. The location differs based on your OS:
MacOS:
rm /Users/<user_name>/Library/Application\ Support/Postgres/var-9.6/postmaster.pid
or using Postgres.app:
rm /Users/<user>/Library/Application\ Support/Postgres/var-10/postmaster.pid
Linux:
rm /usr/local/var/postgres/postmaster.pid
I have the database working now.
Here are the steps I took:
I rebooted my computer
I opened the terminal and ran cd /
Then I did ls -la
Ensured that I could get to MackintoshHD/usr/local/var/postgres
Then did ls -la
Here I saw the postmaster.pid file
I ran this command cp postmaster.pid ~/Desktop which copied the
file to my desktop.I like to do this if I am deleting files. If
something does wrong i can put it back
Then I ran this command to remove the file from the postgres
directory rm -r postmaster.pid
I went to my pgadmin3 gui and fired it up. and Voila it worked :)
Thanks to #Craig Ringer for his help
I'm using Postgres.app, and the below worked for me:
I entered the commands into my terminal below, locating the Postgres folder beforehand and not using "justin".
$declare -x PGDATA="/Users/justin/Library/Application Support/Postgres/var-9.4"
$pg_ctl restart -m immediate
As Justin explains in his post, the output after this was:
waiting for server to shut down……………………………………………………… failed pg_ctl:
server does not shut down
After entering the command again:
$pg_ctl restart -m immediate
It worked and I got this message:
pg_ctl: old server process (PID: 373) seems to be gone starting server
anyway server starting LOG: database system was interrupted; last
known up at 2015-07-28 18:15:26 PDT LOG: database system was not
properly shut down; automatic recovery in progress LOG: record with
zero length at 0/4F0F7A8 LOG: redo is not required LOG: database
system is ready to accept connections LOG: autovacuum launcher started
Source

Shutdown Windows machine from linux terminal [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 months ago.
Improve this question
I am running an application on linux machine. By giving the ip address of a windows machine as input, the application must shutdown the windows machine. If the machines run the same OS it is very easy but I'm confused how to do it in cross OS.
There may be more setup to do, especially for Windows Vista, Windows 7 and further windows versions, to allow remote shutdown:
Part A) On the Windows machine:
1) Add a remote shutdown security policy:
run secpol.msc
in the program tree, open Security Settings > Local Policies > User rights Assignment
Find the entry Force shutdown from a remote system
Edit the entry, add the windows user account that will be used for shutdown (ex: nouknouk)
2) Add registry keys to disable UAC remote restrictions:
Run regedit.exe as Administrator
Find HKLM/SOFTWARE/Microsoft/Windows/CurrentVersion/Policies/System
Create a new registry DWORD(32) value named LocalAccountTokenFilterPolicy and then assign it the value 1
3) Start remote registry service:
Open cmd.exeas Administrator
Execute the two following commands:
sc config RemoteRegistry start= auto
sc start RemoteRegistry
Part B) On the Linux machine:
1) install the package samba-common:
It depends on your Linux distribution, but for Debian and derivated (Ubuntu, Linux Mint, ...), the apt-get command can be executed like that:
apt-get install samba-common
2) To actually shutdown your Windows machine from the Linux one, run the following command:
net rpc shutdown -f -t 0 -C 'message' -U userName%password -I xxx.yyy.zzz.ttt
Where:
-f means force shutting down all applications (may be mandatory)
-t 0 is the delay before doing it (0 means 'right now').
-U user%password is the local user and his password on the windows machine (the one that has been allowed to do remote shutdown in part A).
-I is the IP address of the windows machine to shutdown.
Command to shutdown windows system from linux -:
$ net rpc -S <ip address> -U <username>%<password> shutdown -t 1 -f
This command can be issued from bash or even set in cron job to shutdown the computer at a specific time and this command is shipped with many distros by default.
It's important to note that the above solution will not work if the username in question does not have a password set (at least that's how it was in my case).
For windows 10 (and below maybe, did not check) users one must go to the firewall settings and enable "Remote Service Management" for the linux box to be able to connect via rpc.
It depends on your infrastructure -- how you authenticate to the Windows machines, whether you can configure them yourself, etc. If it were me, I'd put Cygwin on the Windows boxes, then ssh to them and run shutdown -h. There are surely other ways to do it, of course.
You need a way to launch a shell on the Windows box so you can run th shutdown command built in to Windows.
You can install Cygwin for this, then install an SSH daemon in Windows. Once that's running, your Linux box can run commands on the Windows box just as if it were another Linux machine.
Here are some instructions for setting up Cygwin's sshd in Windows.
Option 1: Install SSH server on windows. Login to this server from any box and call shutdown command. We use Interix(Microsoft's unix like environment). It comes with a telnet server- allows to invoke windows commands from other machines..
Another option:
If you samba installed on windows it can connect to windows and call windows commands
net rpc SHUTDOWN ...
(from http://www.linuxforums.org/forum/red-hat-fedora-linux/60324-remote-shutdown-windows-linux-box.html#post573872 )
Another option:
try rdesktop to the windows machine with shutdown command ( I use it for running windows batch script which has shutdown in it, not sure if you can directly call shutodwn)
For windows 10, install openssh-server following this.
With permission setting by nouknouk here
It should be work by
ssh username#host 'shutdown /p'
Also don't forget to add an inbound rule for RPC in Windows firewall allowing port 445.
Use telnet command in Linux, make sure telnet is enabled in Windows system

Resources