my development server has a running Gnome-Desktop. I am connected to it by a ssh session. The Gnome-Session and the ssh session are running with the same user.
How to I start a Gnome-application (for example gedit) from the ssh remote session so that it appears on the remote servers Gnome-Desktop?
Thanks a lot,
Hacksteak25
This would probably work:
Tcsh:
setenv DISPLAY :0
gedit
Bash:
export DISPLAY=:0
gedit
If you are not the user that is logged into the Gnome session, then you would need to do xhost + to disable the authentication.
If the above doesn't work, then instead of :0, try simply copying the DISPLAY environment variable to the ssh terminal.
To support DBUS messaging, use:
ssh -Y remoteuser#remotehost dbus-launch -f gedit
The "-f" option starts the remote GUI application on the local desktop and returns, leaving the local terminal available for the next command.
Related
I connect to a remote linux using ssh and I need to get only a window with x11vnc, i.e., I need to execute:
x11vnc -id -display :0
Every command I try in the ssh session (xprop, wmcrtl, etc.) returns info about the local xwindows system, not about the remote one, so I don't know how to get information of the windows running in the remote machine.
I can't get the while desktop with x11vnc because it is locked and I get only a black screen. I would try the '-id pick' option if had access to the desktop.
Every command I try in the ssh session (xprop, wmcrtl, etc.) returns info about the local xwindows system, not about the remote one
I assume this is because you connect using ssh -X or something similar. That way ssh sets DISPLAY to point to a tunnel it created to your local X server so that remote commands can display output on your screen. Try to override this variable, examples: DISPLAY=:0 xwininfo -tree -root or DISPLAY=:0 xprop -root|grep ^_NET_CLIENT_LIST.
I am trying to call an installation of node.js on a remote server running Ubuntu via SSH. Node has been installed via nvm.
SSHing in and calling node works just fine:
user#localmachine:~$ ssh user#remoteserver
(Server welcome text)
user#remoteserver:~$ which node
/home/user/.nvm/v0.10.00/bin/node
However if I combine it into one line:
user#localmachine:~$ ssh user#remoteserver "which ls"
/bin/ls
user#localmachine:~$ ssh user#remoteserver "which node"
No sign of node, so I tried sourcing .bashrc and waiting 10 seconds:
user#localmachine:~$ ssh user#remoteserver "source ~/.bashrc; sleep 10; which node"
Only node seems affected by this. One thing I did notice was that if I ssh in and then check which shell I'm in it says -bash whilst if I ssh direct it gives me /bin/bash. I tried running the commands inside a bash login shell:
user#localmachine:~$ ssh user#remoteserver 'bash --login -c "which node"'
Still nothing.
Basically my question is: Why isn't bash finding my node.js installation when I call it non-interactively from SSH?
Another approach is to run bash in interactive mode with the -i flag:
user#localmachine:~$ ssh user#remoteserver "bash -i -c 'which node'"
/home/user/.nvm/v0.10.00/bin/node
$ ssh user#remoteserver "which node"
When you run ssh and specify a command to be run on the remote system, ssh by default doesn't allocate a PTY (pseudo-TTY) for the session. Not having a TTY causes your remote shell process (ie, bash) to initialize as a non-interactive session instead of an interactive session. This can alter how it interprets your initialization files--.bashrc, .bash_profile, and so on.
The actual problem is probably that the line which adds /home/user/.nvm/v0.10.00/bin to your command PATH isn't executing for non-interactive sessions. There are two ways to resolve this:
Find the command in your initialization file(s) which adds /home/user/.nvm/v0.10.00/bin to your command path, figure out why it's not running for non-interactive sessions, and correct it.
Run ssh with the -t option. This tells it to allocate a PTY for the remote session. Or add the line RequestTTY yes to your .ssh/config file on the local host.
I have a Linux box (Ubuntu Server 13.04) which needs to run a job on a Windows 7 box (with cygwin installed) under a specific user's account. I have set up a password-less login to access the Windows machine through openSSH.
The problem I face is the following: when I manually ssh into the Win7 machine and launch the job everything is fine. However, when I launch the job using ssh winuser#winmachine command, I end up connecting to the Windows machine under the privileged sshd user 'cyg_server':
$ whoami
linuxuser
$ ssh winuser#Win7
$ whoami
winuser
$ exit
$ ssh winuser#Win7 "whoami; exit"
cyg_server
>> This should be 'winuser' too.
Why could this be happening? I have tried running ssh-host-config again to no avail. I don't see what parameters might influence this in sshd_config either.
Any help is greatly appreciated!
I had similar issues when I was connecting to a Cygwin machine using SSH. I used to have no problems logging on until one day I noticed that my path wasn't set correctly. I spent ages recreating the configuration files with ssh-host-config only to find my answer in the man page for ssh:
If command is specified, it is executed on the remote host instead of
a login shell.
The problem was the alias I had used to connect to the machine had been changed to connect to a screen session automatically (screen -DR). That meant that if there wasn't already a screen session to attach to, screen was not being run as a child process of a user login shell and not inheriting any of the relevant user environment.
When you provide a command as an argument to ssh, the resulting command is run as a process started by cyg_server. Ensuring the SSH command is being run as part of a login shell should do what you want:
ssh winuser#Win7 "bash -l -c 'whoami; exit'"
Explanation (from the bash man page):
-c string If the -c option is present, then commands are read from string.
-l Make bash act as if it had been invoked as a login shell.
So normally people ask how to forward x11 to the local machine, but rather I want to leave the application running on the remote box's desktop.
So let say I ssh from a windows machine (using putty) and run xclock & disown. If I then walked over to my desktop and look at the screen and see xclock running on the linux machine.
Any way to do that? Using Mint 13.
This works for me once I'm ssh'd in:
export DISPLAY=:0; nohup <command> &>/dev/null &
For example:
export DISPLAY=:0; nohup iceweasel &>/dev/null &
When you're ssh'd in normally, set the DISPLAY variable with export DISPLAY=0:0 (0:0 being the display of the target box), and then you can run your command as you normally would. If you want to be able to close the ssh session, prepend the command with nohup: nohup ./yourcommand > dev/null.
h4bo --> That worked. just had to make the script.
First part of learning ssh stuff. Now instead of leaving teamviewer (a remote desktop program) open all the time, I can launch when I need it and then use it.
i guess
nohup ssh -X <ip address> <application name>
I recently had to do some python tkinter development on a Raspberry Pi with Thonny, where I wanted the tkinter graphics to show on the Pi's X server. For this specific purpose, I created a /usr/bin/pythonx script which simply consisted of:
#!/bin/bash
DISPLAY=:0 python "$#"
This wrapping technique works when Thonny ssh's into the Pi where the user is also logged in at the GUI desktop, as the ssh user has access to the .Xauthority data needed to send X client requests (application) to the server (GUI).
I have a vncsession running on server. Now, whenever I open a new terminal, I have to ssh to another server.
Till now I have been able to setup ssh such that it doesn't ask for password for this particular server. But I have not been able to automatically do this in new terminal. If I add the ssh command to .tcshrc it goes into recursive loop - ssh into server, execute .tcshrc, ssh to server, so on.
I'm using Linux, cshell, Gnome setup.
You should do a hostname check or other check that allow you to recognize the difference between the client and the target. I don't know cshell scripting but in SH you would want to do something like:
# Shell:
if [ $HOSTNAME == "vncserver" ]; then
ssh $TARGET_BOX;
fi;
# Cshell:
if ( $HOSTNAME == 'vncserver' ) then
ssh $TARGET_BOX;
endif
This would enforce that only the svnserver would ssh to the remote system and the remote system won't ssh to itself.
I use ssh-agent and keychain that works like a charm and allows keeping some safety on your servers. Here is another keychain tutorial (sorry, written only in french). Just putting your keychain commands in your bashrc or profile that runs at tty start.