I'm trying to connect to my office PC through VNC. I'm using Ubuntu 18.04 on both computers. SSH is normally installed on the office PC, I generally use it to connect from there to other servers. I can also connect to one of the institute's servers, and use putty from there to log into my PC, but I wanted to try to connect to the computer without passing through the server, if possible.
I followed a couple of tutorials to set up the VNC server on my office computer, this is what I did:
- I installed VNC server by: "sudo apt-get -y install tightvncserver";
- started the session with "vncserver" and set up the password;
- configured VNC to use default GNOME desktop, so I modified the ~/.vnc/xtartup file this way:
#!/bin/sh
def
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
xrdb $HOME/.Xresources
xsetroot -solid grey
gnome-session &- started the VNC server by: "vncserver -geometry 1280x720 -depth 24". The server is running normally
Now, I'm trying to establish a SSH tunnel using:
ssh -L 5901:localhost:5901 -N -f -l USER IP
(I was planning to use Remmina to connect to localhost:5901), but I'm getting the error:
ssh: connect to host xxx.xxx.xxx.xx port 22: Connection refused
I ran sudo service ssh status on the office PC, and I got:
● ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2020-03-13 16:23:27 CET; 2 weeks 2 days ago Main PID: 1870 (sshd) Tasks: 1 (limit: 4915) CGroup: / └─1870 /usr/sbin/sshd -Dany idea how to fix it?
21 Answer
ssh: connect to host xxx.xxx.xxx.xx port 22: Connection refused
"Connection refused" means that your ssh client sent a connection request to the server, and it received a response saying the server rejected the request. This normally means that no process on the server is listening for connections to the requested address and port.
The simplest explanation is that the sshd process isn't running on the remote server. Or it is running, but it's not accepting requests on address xxx.xxx.xxx.xx port 22. It might have been configured to listen on a different port, or a different IP address. Alternately, there may be a firewall blocking your connection requests, although that usually produces a different error.
Try running "netstat -an | grep 22" on the remote server and look for a line like this:
tcp4 0 0 *.22 *.* LISTEN "*.22" means "any address, port 22", and "LISTEN" means that there is a process listening for connections. If you don't see a line like this,
2