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

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

Related

open Teamviewer on a Debian machine via PuTTY on a Windows machine

hope everyone is doing well.
Got an issue I would like to pick the great brains in this forum about.
So, I have many Debian machines I often remote into using Teamviewer and a Windows machine, which works out great; however Teamviewer crashes for what appears to be no apparent reason. When such happens, normally I will PuTTY into the suspect Debian machine from a Windows 7 machine and issue the shutdown -r now command. When the debian computer reboots, so does Teamviewer and the suspect Debian machine is now visible in the "My computers" list on my Windows machine.
My question is this, why cant I just type teamviewer from the command line while PuTTYing into the Debian machine and have Teamviewer reopen on the Debian machine, making it visible in "My computers?" When I execute teamviewer command from PuTTY command line, I see the verbose output of teamviewer opening, but the machine never becomes visible in "My computers."
Now, I know it is possible to start Teamviewer remotely and have it show up back in 'My computers" list. I can do it via NoMachine; I simply connect to the suspect Debian machine and double click on the Teamviewer desktop launcher. However, NoMachine is very heavy and quite frankly, i just don't like it. I also know I can execute teamviewer via command line while sitting in front of the suspect Debian machine. PuTTY would be so much faster.
I have also tried VNC as well as X sessions. In both cases, i can open Teamviewer and it shows up in "My computers," but when I close the VNC of X, Teamviewer also closes and removes itself from "My computers."
Can someone help me figure out a way to restart Teamviewer via PuTTY please? Is there a way to open a desktop launcher via PuTTYs command line? Or is there a way to tell Teamviewer to execute in the suspect Debian machines active desktop session via PuTTYs command line?
Thanks all

Can I use emacs on my computer to compile C code via ssh to a linux terminal?

So I just started a computer science course and we are learning C. Well, we are supposed to know it already. They suggested that we use emacs to write our C code.
So what I do is use putty to ssh into one of the linux computers in the lab. I am wondering if i can download emacs onto my laptop instead of using the one in the terminal. So i have a session open on one of the computers in the lab from my laptop but i am using a program on my laptop to compile the code. Hopefully that makes sense.
I am wondering if this is possible or do i have to use the emacs within the terminal (the one that's not color coded and looks nice.)
I'm not sure I understand all your requirements, but all the following can be done:
Install Emacs on your machine; install a C compiler on your machine; and do all your work locally.
Do all the work remotely in putty (as you've been doing, apparently).
Install Emacs locally, to edit and compile remote files (i.e. the files stay on the GNU/Linux server and are compiled there, but you edit them in your local Emacs, via Tramp which internally accesses them via ssh).
You can install precompiled binaries for the above, or you can compile them yourself.
Even better, you can install GNU/Linux on your machine, so that installing Emacs or a C compiler is then a simple matter of "aptitude install gcc emacs".

SSH tunnelling into arch box

I have a raspberry pi running arch linux connected to the TV and want to run commands on that screen by SSH'ing from my Ubuntu machine elsewhere.
I have tried running the command SSH -Y root# and starting xclock as a test. However I get the following error:
No protocol specified
Error: Can't open display: :0
I then tried running "export DISPLAY=:0" on the arch machine, but this doesn't solve the issue.
I have X running fine and can see it on the TV and I have edited the file /etc/ssh/ssh_config to allow X11 forwarding.
Anyone know what I am doing wrong?
Many thanks
The ArchLinux wiki has some good instructions on setting things up. I struggled for a while until I found them, but for me the key was to set up SSH forwarding within sshd_config (most distros seem to enable this by default, but Arch doesn't).
Once you've enabled X forwarding in SSHD, I also found it helpful to install the dummy video driver for Xorg ("pacman -S xf86-video-dummy"), which gets rid of irritating errors about missing the RANDR extension. This might not be necessary if you already have it running a real X server locally on the Pi - personally, I'm running mine completely headless.
I've found that I don't have to worry about setting up the DISPLAY variable, or xhost, when running with 'ssh -X' from an iMac. I'd expect Ubuntu to behave the same.
looks like an authentication problem. The answer used to be
xhost +
on the console of the X display. Might help.
You probably want to set
export DISPLAY=[IP_ADDRESS_OF_ARCH_BOX]:0
on your Ubuntu box, then when you run xclock from your Ubuntu box, it'll forward the screen to the Arch box.

Can't get remote desktop to open in x11 window through ssh

I am having trouble getting an x11 window of the desktop of a remote machine.
I am VPN'ed into a local network and I can get into the computer I want through the command line using:
ssh -X computer_name -l login_name
I thought that the -X would cause the remote machine's desktop to pop up in x11, and although x11 launched on my mac, I did not get an x11 window of the machines desktop.
I can get things like emacs to run and pop up in new x11 windows, but I want to get the whole desktop going.
I am running Mac OS 10.7, and the remote machine is running linux.
Any help would be appreciated.
Figured it out.
after the command
ssh -X computer_name -l login_name
I had to start a gnome-session
gnome-session >&/dev/null &
this gave me the linux desktop in an x11 window.
ssh -X (or -Y) only tunnels the connection to your local X server for the applications started on the remote machine from your SSH session. It cannot do anything about the desktop environment that is running on the remote machine's own X server.
You're probably looking for something like VNC, not X11 forwarding.
X-Window allows you to run programs remotely, and have their windows appear locally on your machine. As you stated, you were able to get this working properly. If you want to see the entire linux desktop on your mac, you will want to use a program like VNC.
You will need to run vncserver on your linux machine, then you can use any of a number of VNC clients on your mac to see the entire linux desktop. For example, Chicken of the VNC.
If you want your remote Linux desktop to be displayed on a window on your Mac you should use on your Mac (providing that the VPN is already setup and running, you have access to your Linux server, and XDMCP is configured on it):
$ Xephyr -query <linux-ip-or-name> :1

Attach/Detach to a remote instance of Eclipse

When using Eclipse over X-Windows on a remote shell (X port forwarding), is there a way to simply detach my X connection and come back to the process later. For a little more clarity, I'm on a Windows machine and have to reboot. I'd like to keep Eclipse running and come back where I left off. Eclipse is running on my Windows machine through an X-Server connected to a Linux box.
I'm thinking something like tmux could do the trick. However, I do a Ctrl-Z to stop Eclipse and it won't close the Eclipse Window. If I restart the X-Server in Windows, Eclipse fails when I try fg 1. Any other options?
Xpra did everything that I needed, but it was not clear exactly how it worked. I was able to get it working by opening two PuTTY sessions in windows, one server and one client. Also, the Google Code is out-dated. Instead, install from http://xpra.devloop.org.uk/dists/xpra-0.0.7.9.tar.bz2. I'm not sure how it's different, but it worked for me. The README tells how to build the package. It is necessary to apt-get a bunch of other stuff. But, here are the missing pieces on how to get it work as I describe above:
Setup server:
cd ~/download/xpra/xpra-0.0.7.9
export PYTHONPATH=$PWD/install/lib/python:$PYTHONPATH
./install/bin/xpra start :10
export DISPLAY=:10
xterm&
Setup client:
cd ~/download/xpra/xpra-0.0.7.9
export PYTHONPATH=$PWD/install/lib/python:$PYTHONPATH
./install/bin/xpra attach :10
Notes:
The Windows xpra installer is not needed for this configuration. I don't know what it's supposed to do.
Be sure to run Xming on Windows.
Be sure to enable X port forwarding on the client PuTTY window.
Launch whatever you want from the xterm window. (ie Eclipse)
You can close the server window once xterm is up.
Hit ctrl-c in the client window to detach from the session.
Do all the client commands again to re-attach..even after restarting PuTTY, the Xming, or Windows itself.
I have zero experience with it, but xpra sounds like exactly what you're looking for.

Resources