Problems to create ssh tunnel from Windows to Ubuntu with VNC - linux

I have Windows (client) and Linux (server).
I want to have a VNC access over ssh to Linux.
I use Port 2222 as ssh port.
I managed to install the ssh and login to the linux server via ssh using public key without password.
I have tried several configurations via windows console, which also work:
ssh -l user -L 5901:localhost:5901 xxx.xxx.xxx.xxx -p2222
OR
ssh -L 5901:127.0.0.1:5901 user#xxx.xxx.xxx.xxx -p2222
But when I try to go in via VNC viewer (Windows) with xxx.xxx.xxx.xxx:5901, the connection is interrupted.
I change the default "sshd_config" to:
AllowTcpForwarding local
X11Forwarding yes
Port 2222 at ufw is open.
Which mistake I make?
Is the port 5901 right to use?

From the fact that you are doing ssh port-forwarding, I understand xxx.xxx.xxx.xxx:5901 is not directly accessible from your Windows machine.
Can you try to go in via VNC viewer (Windows) with localhost:5901, after setting up ssh as follows ?
ssh -X -L 5901:127.0.0.1:5901 user#xxx.xxx.xxx.xxx -p2222

Related

Different pulic key for jump host and destination host over ssh

I have HOP server (bastion) and APP server. I am able to ssh to HOP server via:
$ ssh HOP
I am able to ssh to APP server from HOP server:
$ ssh APP
Both SSH works without password, only via ssh keys.
During ansible deploy I find out I cannot connect to APP server via HOP. I am testing it over cmd:
ssh -o ProxyCommand="ssh -W %h:%p HOP" APP
After this, I am able to connect to APP server but it requires password. I find out, even when APP ssh works from HOP, now it cannot detect configuration from HOP server. So I defined the public key to use in command line:
ssh -o ProxyCommand="ssh -W %h:%p HOP" APP -i /etc/ssh/my_ssh_key
Warning: Identity file /etc/ssh/my_ssh_key not accessible: No such file or directory.
But now, It tried to locate my_ssh_key on localhost, and it asks for password again.
How can I force the use configuration from HOP server or define to use SSH public key from HOP and not from localhost? Is it even possible?
I have achieved this by following this approach:
Ansible host file changes to use bastion host under host group:
[testservers]
192.168.20.140
192.168.10.88
[testservers:vars]
ansible_port = 22 # remote host port
ansible_user = ec2-user # remote user host
private_key_file = /Users/laptop-ansibleuser/.ssh/id_rsa # laptop key to login to bastion host
ansible_ssh_common_args='-o StrictHostKeyChecking=no -o ProxyCommand="ssh -o \'ForwardAgent yes\' ansible-remote#<bastion host> -p 2222 \'ssh-add /home/ansible-remote/.ssh/id_rsa && nc %h %p\'"'

Connect to a VNC inside a docker which is on remote server

I have an Amazon Linux AMI server on AWS EC2, i have deployed "selenium docker" on it "https://github.com/elgalu/docker-selenium", the docker have a VNC running inside it.
Now how i could access this VNC?
I did some google search but did not found anything, also i tried to connect to the server ip and give the VNC display number but it gives connection refused.
I have added the VNC port as a rule on the server security rules.
Thanks.
Since you have already specified the firewall rules for your VNC server the problem is most likely in VNC port listening.
first, make sure that VNC is running on localhost run
nc localhost 5901
nc = netcat (you may need to install the package)
change 5901 to your port no
you can also view the running VNC instances by :
vncserver -list
now if everything seems to be working run this command to show the port stats
sudo netstat -ntpl | grep 5901
change 5901 to your portname.
if something like
127.0.0.1:5901 is assigned to tcp then that's the problem , we need to make sure VNC is running on
0.0.0.0:5901
which means it should accept all the traffic and not just localhost !
finally kill the vncserver by running vncserver -kill :1 (display name), run the command :
vncserver -localhost no
P.S its an old question but may help future answer seekers.

Setup ssh to connect 2 PC and use MPI

I am here because I've found different problems setting up SSH using this guide proposed in this other question.
First of all I've a computer (I want to use it as master) called: timmy#timmy-Lenovo-G50-80. My other computer is a Virtual Machine always with linux mint called: test#test-VirtualBox and I'd like to use it as a slave.
What I've done until now is:
install needed packets (both PC):
sudo apt-get install openssh-server openssh-client
Change inside the file /etc/ssh/sshd_config: (Only master)
the port of server from 22 to 2222
set PubkeyAuthentication yes (so no change)
remove comment at line: Banner /etc/issue.net
STOP
I am stuck when I've to execute this command:
ssh-copy-id username#remotehost
I imagine, reading what's written, that I've to execute something like:
ssh-copy-id timmy#timmy-Lenovo-G50-80
but:
from timmy#timmy-Lenovo-G50-80 everything goes OK, I can connect to myself (not what I actually want)
from test#test-VirtualBox it tells me ERROR: ssh: Could not resolve hostname timmy#timmy-Lenovo-G50-80: Name or service not known
Finally, what I've to do in order to connect these 2 PC?
You need to enable port forwarding into your VirtualBox'ed machine. Simply right click on the virtual machine, then go into Network. Then click on advance which will expand the Network window, and then on the button that appeared labeled Port forwarding.
A table will appear with several columns (Name, Protocol, Host IP, Host Port, ...). Simply add a new entry for protocol TCP, host port = X and guest port = 22 (see the list of well-known ports here https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports). The screenshot below is from my cloudera quickstart VM. Notice the outlined entry in the port forwarding rules, which is about setting up the SSH port in the guest OS.
Once you reboot the virtual machine, you can simply connect to it through
# ssh -p X localhost
the -p parameter tells to connect through the port X. Notice that if you want to use scp then you have to use the uppercase -P option rather than the lowercase -p.
# scp -P X localfile localhost:remote-dir/

Connect two local linux computers via ssh

I would like to know how to connect two linux computers (Ubuntu and OpenSuse) via SSH. When I try to run this command on Suse:
ssh 192.168.1.37
I get error:
ssh : connect to host 192.168.1.37 port 22 : connection refused.
When I try to connect from Ubuntu PC with the same command and Suse's IP, I get "connection timeout" error.
Any help would be appreciated.
Install SSH server in the machine you want to connect, by issuing the command:
sudo apt-get install openssh-server -y
After that, you can connect to that machine by executing the following command:
ssh user#ip_address
where user is the name of the user in that machine you want to connect to with which you want to be authenticated, and ip_address is the IP address of that same machine.
When logging in, try to specify the user you want as well, so that the command looks something like this
ssh example#192.168.1.37
Try using this if its default user
ssh root#192.168.1.16
ssh root#device_ip_address
root is the default user for dietpi
Try the following command by specifying the username followed by # and the IP address (i.e. the hostname).
ssh user#192.168.1.1
Here, user is the username of the user in the machine you want to connect to, followed by the IP address of the host, which in this case is 192.168.1.1.

Using Coda to access server SSH/sFTP

I have a VPS server and I lock down to only expose 3 ports 80, 443 and 22222 for ssh. So far I can connect to the server using Terminal (Mac) and Panic Transmit, but when I try to connect using Panic Coda the connection fail. What I am doing wrong?
I see Coda support sFTP and I can connect on Coda to the SSH, but not to the sFTP.
Ideas? Work around?
Thank you
As to what coda is actually doing, I can't say for sure.
Workaround could be to create an ssh tunnel and just use FTP, configure your FTP server or firewall to only allow loopback connections
Establish tunnel using something like:
ssh -o'Port 22222' -f user#server -L 3000:127.0.0.1:21 -N
Then point FTP at localhost, port 3000.
HOWTO: SSH Tunneling Made Easy

Resources