How to reconnect to lost VNC server on mac - macos

I'm using ssh tunneling, vncserver, and the default Mac Screen Sharing app to run a GUI on a remote server (university clusters). It works really well in general, but often if left too long or after moving my laptop to another wifi network (eg, from home to campus) I lose connection to the remote server and Screen Sharing gets stuck in the "Reconnecting" forever.
It appears that the GUI is still running on the remote server because when I write vncserver -list in ~/.vnc it still has the .pid file (and I never used the -kill command). How can I reconnect to this vncserver? When I enter vnc://localhost:59xx in Screen Sharing it says
Connection failed to "localhost".
Make sure Screen Sharing or Remote Management is enabled on the remote computer
I'd really like to reconnect to this remote server because I'm running time-consuming and time-sensitive processes that I need to check the status of from time to time, and I need to make sure that the program successfully saves the output of my program.
Thank you!

Figured it out. I didn't realize that the localhost was based on my IP address, so when I moved locations the ssh tunnel collapsed. All I had to do was recreate the tunnel (ssh -L 59xx:localHost:59xx -N -f name#cluster.edu and I was able to reconnect to the port with Screen Sharing.

Related

Can't SSH into EC2 from my mac but can from other devices

I am trying to connect into an EC2 instance (i am using a mac) which has a Security Group allowing all inbound traffic over ssh (port 22) but i'm unable to access. I'm having a little delay before getting an Operation timed out.
I already tried it over other devices such a raspberry pi and another macbook and the connection was successful.
I got access to the raspberry pi over ssh and tried the connection to my EC2 from the terminal; thought my ssh client or the port status could be the issue but after doing this i'm not really sure if this is the case.
This is the message i get when trying to connect:
ssh: connect to host x.x.x.x port 22: Operation timed out
One thing I noticed is that I used a different .pem file which is supposed to not work for that instance and the error was the same, it looks like my Mac cannot reach it.
Things already verified:
Security Group allowing traffic over port 22.
Instance rebooted/recreated.
DNS and Public IP address changed after instance reboot.
SSH connection successful over other devices.
SSH connection to other devices from this mac successful.
Firewall turned off.
DNS flushed.
Ping performed with success.
Any help is really appreciated it.
-- UPDATE --
This issue rose in my work machine. Got a different laptop due to other issues and problem fixed, looks like it might have been something related to ports or some sort of configuration. Thought it was a problem with AWS but now it's working fine. Sadly I couldn't debug enough to know what the exact issue was. Thanks to everyone who helped out!
It seems that you can remote by other devices and this issue is only still happening on your MAC. Try this on your MAC and try to remote again:
Flush your DNS
I don't know which Mac OS you are using so I put the link here: (https://help.dreamhost.com/hc/en-us/articles/214981288-Flushing-your-DNS-cache-in-Mac-OS-X-and-Linux)
If still cannot, you can try to open some protocol ports on that instances like:
ICMP, Echo Reply, ...
then try to reach by that protocol commands:
Ping, telnet, ...
If the result is cannot too, so it must be that your MAC cannot even reach to that instance network, then try to ensure that your MAC can reach the instance's network first.

Why SSH server on windows7 x86 failed, while SSH client working

I am working recently on building Hadoop environment on windows7 OS. However, I got stuck in SSH configuration which blocks all the remaining work for Hadoop. I believe it's nothing to do with Hadoop, so any one familiar with SSH can do me a great favor.
Here's the thing, I'm trying to install SSH service for two computers so that any one can communicate with the other. I have successfully installed SSH for my PC, which is win7-x64, through cygwin. However, when I repeated it on the other computer, which is a server with win7-x86, SSH server failed, while the client can work, I get totally confused.
For my PC, I installed cygwin to use SSH service. ssh localhost works fine. And after generating ssh keys and appending it to authorized_keys, I managed to log in to my PC without password.
I copied the cygwin folder from my PC to the server, which is not connected to the Internet thus cygwin can't be directly installed on it. ssh localhost turned out okay at the first. But when I attemptted to log in without password by generating ssh keys and appending to authorized_keys, I got
Connection to localhost closed by remote host
Connection to localhost closed.
What's more, I copied the public key of the server to my PC and appended to authorized_keys file. I managed to log in to PC from the server without password.
On the other hand, the SSH connection from PC to server failed no matter whether with or without password. I got the same failure:
Connection closed by 192.168.0.52
where 192.168.0.52 is the ip address of the server.
What makes me more confused is when I connected to server from PC using putty rather than ssh command, I could log in to the server, with password.
In conclusion, I hope it would make the question more clearer with this graph:
ssh connection graph
I hope any one can help me to figure out what's wrong and how to fix it. Thanks a lot!
After trying for several centries, I finally found what's happening. When I built sshd service on the server, I didn't create a privileged account('cyg_server' by default), which I did on my PC but I forgot. Instead, I used current account for logging. Yet, the account , even the administrator, on windows doesn't have all the authorities as root on Linux does. Considering that, Cygwin considerately creates a privileged account named 'cyg_server', we just leave it and log in using current account. Everything is okay!
Again, f**k windows(So why would I have to do that on windows. Well, if I could, I would)

Detect RDP Session on Remote WinXP machine (not on local network or domain)

I have set up a Win XP machine at work that we use as our server, to allow RDP connections. This allows all our staff to access the server from home when needed. As it is not a server OS, we are missing many of the terminal services features a regular server would have. The machine only allows one RDP session at a time (which is a minor inconvenience, but not a big deal).
What is bothersome, is that no one can tell if the server is currently being used in an RDP session, and we all keep booting each other off. Every solution I have found online assumes the remote computer is a Server OS or on a local network/domain. Our staff's home computers are not connected to the office network and we have no domain set up at the office.
Is there any way to tell if the server is in an RDP session before remoting onto the server from home? Ideally we would be able to detect which home computer is accessing the server. But if that is not possible, it would be extremely helpful to at least know that an RDP session is running.
We were previously using logmein, which could tell us if the remote computer keyboard and mouse were active and allow a chat with the user currently remoted on/physically on the machine. This was extremely convenient, but involves logging onto the logmein website and going through a semi-lengthy process of connecting. It is also much slower and resolution is much worse than RDP. Not super convenient for regular daily use.
This post deals with the same issue
https://superuser.com/questions/313390/ways-to-check-if-user-is-active-on-remote-machine-before-rdping
but the accepted response is to use qwinsta on cmd, which I believe is only available on server OS's. Other responses include using psexec (I've tried using psloggedon.exe, but this appears to only work for users on the same domain). Another suggests using the wmic.exe command, but when I try that I get the error: The RPC Server is unavailable (I think this also needs to be run on the same domain).
So basically - is there any way to check for active rdp sessions on a Win XP machine from a remote computer not on the local network/domain?
I'm open to outside-the-box solutions like writing a simple app to run on the xp server and tell remote machines what IP is connected in an RDP session.
Going on Harry Johnston's suggestion, I wrote an app which finds who is connected to the xp machine on port 3389, and relays that information by udp to receiving apps. Now we can check if someone is connected and who it is before unwittingly booting them off. Thanks Harry!

X forwarding through NAT

I'm trying to install Oracle 11g from scratch on an AWS Linux machine. In order to do so, I believe I'm required to enable X forwarding so I can use the graphical installation. I have never been good with X server/client situtations.
Setup:
cygwin64 (local)
NAT instance (Amazon)
Linux instance in private subnet accessible through said NAT (Amazon)
I'd like to forward the Oracle installation from the Linux instance through the NAT and to my local machine. Any help would be appreciated. I'm happy to provide more information, especially since I haven't provided much so far. I'd also love to hear that I'm going about this all wrong and that it's easy to install Oracle from the command line.
The client and server seem "backwards" in the world of X, because your workstation is the "server," providing the service of a display device and keyboard/mouse... while the program you are running, often remotely, is the "client," using those display and input devices services.
So the program you want to run needs to be able to connect "backwards" to your machine, but you can forget, for a moment, about the NAT aspect, because that's not directly relevant. The important thing is that you have a way to establish a chain of SSH connections from end to end, and that should be all you'd need, because SSH does the work. No firewalls were harmed in the answering of this question.
I don't know what kind of SSH utility cygwin has, but it will presumably be comparable. I tested the following first when end to end Linux, and then by replacing "ssh" with "\Program Files (x86)\PuTTY\putty.exe" on a Windows 7 desktop machine for the workstation. Both scenarios worked as expected, and the arguments are conveniently the same.
We'll call the NAT machine hostname "natbox" and the database "databox".
On your local machine, your X server is presumably listening on port 6000, so we need to get traffic back to it.
workstation $ ssh -R 127.0.0.1:5555:127.0.0.1:6000 natbox
I chose 5555 arbitrarily, but any unused value above 1024 should work. You could also use 6000 also but it makes the example even more counter-intuitive than it already is.
The first IP/port pair 127.0.0.1:5555 refers to the remote machine (natbox). Your SSH session will open a socket listening on port 5555 of the the loopback interface on the remote machine. The second IP/port pair 127.0.0.1:6000 refers to your workstation, which is the place the traffic is to return to. Connections to port 5555 on "natbox" will be tunneled back on your workstation, where an attempt will be made to connect to your local port 6000.
natbox $
So now we're logged in to natbox, and the tunnel is half-built.
natbox $ ssh -R 127.0.0.1:6000:127.0.0.1:5555 databox
This makes an SSH connection to "databox" where it opens up a listen socket on that server's port 6000 bound to the loopback address. Connections hitting that port will be sent back down the ssh connection to "natbox" where they will try to connect to natbox's port 5555... which, in the prior step, we already have linked back to your workstation's port 6000 -- your X server.
databox $ export DISPLAY=:0.0
databox $
Done.
Any X client program run on "databox" will try to connect to the local machine's display '0' on port 6000... which should end up back at your console.
databox $ xterm
This should open up a terminal window from "databox" on your local display. You don't need this, but it's probably going to be easier to verify and troubleshoot the X setup without dragging the Oracle componentry into the mix.
Note, the first reference to 127.0.0.1 (and the : between it and the first port number) on the ssh -R option are actually implicit, but I included them because it seems slightly less counter-intuitive to me. It is also possible to set this up in a cascade on a single command line, by providing the "command to execute" on the intermediate machine as the final argument to "ssh" on the local machine, as long as you add a -t to the first ssh so that it knows you want a tty end-to-end... but it was already complicated enough, so I didn't include that.

remote execution in windows server via telnet

I need to start a process and keep it running on several remote windows (03 and 08) servers.
When I telnet in and start the process and sign out of my telnet session, the process dies.
I changed the registry settings so the pertinent tlntadmn output looks like this:
End tasks on disconnect : NO
restarting the service and/or rebooting the server have had no effect. My processes still die when the telnet session ends.
Any advice?
My advice would be to ask this question at serverfault.com, which is similar to SO but focuses on sysadmin stuff. As I know near nothing about telnet, if you can't figure this out take a look at PsExec, which will let you run executables on remote machines in various ways.

Resources