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).
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 using Linux containers with Proxmox 4.
When I am connected on an Ubuntu 16.04 container with:
pct enter <id>
I run a script with screen and try to watch the process running with:
screen -x <processname>
I got the error:
Must be connected to a terminal error
When I connect with:
ssh -t <user>#<container_ip>
It works, I can attach the display to the screen.
How can I use screen -x when I am connected with pct enter ?
I found a solution that works for same case(https://www.svennd.be/screen-in-lxc-attach)
Execute this
script /dev/null
Then you can run screen, et voila
This is happening mostly because of the reason that you must have
switched user
to the current terminal user using the command sudo su or user changing command.
You will need to own the shell on which you are working.
You can do so by running this:
script /dev/null.
Alternatively,
You can restart the terminal session with the user(which was used when creating screen) and not coming to current user using
switch user commands.
To know active screens :
screen -list
Alternatively, You can start the session within "hohup" and send to background
I would like to make a shutdown-script for my raspberry pi to shut down anothe raspberry pi over ssh.
The script works if it is running itself but at the shutdown routine the ssh command is not executed.
So that I have done until now:
Made the script in /etc/init.d:
#!/bin/sh
# the first thing is to test if the shutdown script is working
echo "bla bla bla " | sudo tee -a /test.txt
ssh pi#10.0.0.98 sudo shutdown -h now
Made it executable
sudo chmod +x /etc/init.d/raspi.sh
Made a symlink to the rc0.d
sudo ln -s /etc/init.d/raspi.sh /etc/rc0.d/S01raspi.sh
Now I know so far that the shutdown script is working outside of the shutdown routing by calling itself and the shutdown symlink I made is also working partially because I see the changes in the test.txt file every time I shut down.
Can anyone help me how to solve my problem?
Have you tried with single quotes?
The first link in Google has it
http://malcontentcomics.com/systemsboy/2006/07/send-remote-commands-via-ssh.html
What about the sudo, how do you solve entering the password?
https://superuser.com/questions/117870/ssh-execute-sudo-command
Please check this or other links on the web that have useful information.
I would have send all this in a comment but I cant yet because of reputation.
I have now got the script running by myself. I do not really know why it is now working but I write it down beneath and maybe someone else can clearifiy it.
I don´t think the first two changes at my system makes a difference but I also write it down. In the meanwhile because I do not managed the script to get working I had made a button to shutdown the system manually. Also I made a script which backs the mysql-database up (which is on the Raspberry Pi which I would like to switch off with the script) and copies the backup to the raspberry pi which should switch of the other raspberry automatically via the shutdown-script. This happens with scp and also for the password is a key generated.
I have also changed my script to get a log-message out of the script.
#!/bin/sh
ssh -t -t pi#10.0.0.99 'sudo shutdown -h now' >> /home/osmc/shutdown.log 2>&1
To get it into the shutdown-routine I used:
sudo update-rc.d raspi-b stop 01 0
I hope somebody can say me why my code now worked on the first day but not on the next few days until now.
I structured a command to suspend or shutdown a remote host over ssh. You may find this useful. This may be used to suspend / shutdown a remote computer without an interactive session and yet not keep a terminal busy. You will need to give permissions to the remote user to shutdown / suspend using sudo without a password. Additionally, the local and remote machines should be set up to SSH without an interactive login. The script is more useful for suspending the machine as a suspended machine will not disconnect the terminal.
local_user#hostname:~$ ssh remote_user#remote_host "screen -d -m sudo pm-suspend"
source: कार्यशाला (Kāryaśālā)
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.
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.