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.
Related
Problem: The location I'm working from cannot ssh into the master node for my application, say 10.30.30.1 which is hosted by another country. To solve this, I have a jump box which I can ssh from my location say 10.50.50.1
And after logging into the jump box, I again run the command ssh 10.30.30.1
Is there any way to save me a step of first logging into the jump box and then ssh into master node, because that's the only thing I use the jump box for.
Can I configure the jump box to directly run that ssh command the moment I log in?
Are there any commands which allow me to login directly to master via the jump box in a single command or putty / MOBA XTerm configuration?
Put the following lines into your ~/.ssh/config:
Host target-host
ProxyJump jump-host
This assumes both the server and the client running OpenSSH >= 7.3. For older versions you can use ProxyCommand and netcat instead of ProxyJump. netcat must be installed on the jump host:
Host target-host
ProxyCommand ssh jump-host netcat -w 120 %h %p
Say you first execute ssh server1, then on server1, you execute ssh server2. The thing you want is when you execute ssh server1 on your local computer, you can automatically login to server2.
The way to do this is add a script that runs automatically when you login to server1. You can do this by just adding the code ssh server2 into your ~/.bashrc file (if you are using Ubuntu. Or in other OS, the file name is similar to ~/.bashxxx).
But after doing so, you still need to type password for server2 every time you login into server1. If you don't want to type server2's password by hand, you can use a password-free ssh connection from server1 to server2. See this page to find out how.
i wanted to execute commands on remote linux box from windows and also wanted to collect result of executed command. Basically i have to pass 2 boxes to execute that command here is flow.
Login to a box
ssh to another box
run command
collect output of command locally (in file)
I tried following
F:\xyz>plink xyz#a1.b1.com -i F:\x\y\PRIVATEKEY.ppk -pw xyz
ssh -f root#166.1.8.1 yum upgrade Cyberc
but this is asking for password. I can do it by adding id_rsa.pub value in to authorized_keys but we dont have permission to do. So instead of that i wanted to write EXPECT script to pass user/pass and commands to complete my job.
Any help on EXPECT script would be much appreciated.
Unless the program on the remote linux host is interactive (i.e. it has prompts that the user must respond to), then you probably don't need to use expect - you can simply use plink to connect to the remote Linux host from your windows machine and run the command. You can specify the username and password to authenticate with the remote host in the plink command. See the following links for more info:
http://the.earth.li/~sgtatham/putty/0.58/htmldoc/Chapter7.html
http://stackoverflow.com/questions/12844944/login-syntax-for-plink-using-ip-username-and-password
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).
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.