tunnel interview questions
Top tunnel frequently asked interview questions
I need to connect (in rdp ) to a machine (let's call it #1) in my college network ( I have the internal IP of it ) , I also have access the to Linux server machine in the same network in ssh , that I can use to access the #1 ,
I'm using putty, can someone please explain to me how I can connect to it ?
[My laptop] --->[Linux server] --->[windows machine] in rdp
Thank you,
Source: (StackOverflow)
I've setup a reverse ssh tunnel, using PuTTY, to allow me to VNC into a home computer without having to enable NAT port forwarding. Works great, no problem.
I would like to set the tunnel up as a "persistent service" that will connect on boot up and reconnect when dropped. PS. this is on Windows.
Exhaustive googling found a few products but many seem to have been abandoned and none appear to have major "street cred."
Does anyone have experience with this type of thing or with any of these products? I don't need all the bells and whistles, just reliability.
Source: (StackOverflow)
I'm having a hard time figuring this problem out - I am trying to write a program that will interact with the Linux tunnel driver. At a very basic level, I simply want to create an application that is able to transfer data over a network tunnel. However, I am completely at a loss as to how to properly set up the tunnel driver in order to accomplish this.
I am developing on Ubuntu 9.04, and I have the tunnel driver kernel module loaded.
There exists the device /dev/net/tun, however there are no /dev/tunX devices. I am unable to create these devices using ifconfig - whenever I run /sbin/ifconfig tun0 up, for example, I get the following error: tun0: ERROR while getting interface flags: No such device. If I attempt to look at the /dev/net/tun device, the following error is presented: cat: /dev/net/tun: File descriptor in bad state. Attempting to open /dev/tunX via a small program (basically, a simple tun_fd = open( "/dev/tun0", O_RDWR ) returns -1: the application is running as root and still cannot open this tunnel device. It is possible to open /dev/net/tun, however this does not appear to generate a new /dev/tunX device to use instead.
So, in summary - how does one go about writing an application that wishes to use the Linux tunnel driver? Any insights would be greatly appreciated.
Thanks;
~Robert
Source: (StackOverflow)
I have a connection between my localhost and a remote server using putty SSH tunnel.
Thats fine.
Now I need a command to get the sql file on my local machine i.e. c:\folder\test.sql and import it into mysql on the remote server
I thought maybe...
mysql -u prefix_username -p testpass -h localhost -P 3307 prefix_testdb
then do a command like
mysql -p testpass -u prefix_username prefix_testdb < c:\folder\test.sql
this command did not work.
How can I acheive this?
Source: (StackOverflow)
I am trying to use ssh port forwarding to defeat corporate firewall:
ssh git@GIT_SERVER -L9418:GIT_SERVER:9418
and in another terminal I run
git clone git://localhost:repositories/project.git
But I get the following error:
Initialized empty Git repository in /Users/aboxer/tmp/glucosia/.git/
fatal: Unable to look up localhost (port repositories) (nodename nor servname provided, or not known)
Thanks!
Source: (StackOverflow)
I'm using localtunnel v1. But I found that v2 allows you to customize the subdomain, and I need this feature.
I followed the tutorial described in the README
from the repository, but it confused me in several parts and, in the end, it did not work.
First step is to run some web-app: checked, on port no. 8000.
Then, it says something about hostnames:
Localtunnel does some stuff with the hostname, so you want to set up two
hostnames. One for localtunnel registration, one for your localtunnel.
Normally it expects a wildcard, but we'll just hardcode a hostname for
this example tunnel.
example.localtunnel.local -> 127.0.0.1
localtunnel.local -> 127.0.0.1
You can do this in /etc/hosts or use that fancy ghost utility.
I've got lost here, but still I edited my /etc/hosts
:
127.0.0.1 localhost
127.0.1.1 my-pc-name
127.0.0.1 example.localtunnel.local
127.0.0.1 localtunnel.local
Next step...
Now you can start the server. It's based on a configuration file in the
config directory. You can make your own, but this one is configured to
run the server on port 9999 and expects the hostname localtunnel.local
ginkgo config/default.conf.py
Which one? Anyway... I created myconfig.conf.py based on the files in localtunnel repo's dir /deploy
:
port = 9999
hostname = 'localtunnel.local'
service = 'localtunnel.server.TunnelBroker'
But, when I run:
lt --broker 127.0.0.1:9999 --name example 8000
I got:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gevent/greenlet.py", line 390, in run
result = self._run(*self.args, **self.kwargs)
File "/usr/local/lib/python2.7/dist-packages/localtunnel/client.py", line 53, in listen
msg = self.ws.receive(msg_obj=True)
TypeError: receive() got an unexpected keyword argument 'msg_obj'
<Greenlet at 0xb6e0db1cL: <bound method TunnelClient.listen of <localtunnel.client.TunnelClient object at 0xb6def52c>>> failed with TypeError
And in the ginkgo process:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 438, in handle_one_response
self.run_application()
File "/usr/local/lib/python2.7/dist-packages/ws4py/server/geventserver.py", line 85, in run_application
self.result = self.application(self.environ, start_response_for_upgrade)
File "/usr/local/lib/python2.7/dist-packages/ws4py/server/wsgi/middleware.py", line 131, in __call__
environ.copy()))
TypeError: handle_websocket() takes exactly 3 arguments (2 given)
<BrokerFrontend fileno=6 address=0.0.0.0:9999>: Failed to handle request:
request = GET /t/example HTTP/1.1 from ('127.0.0.1', 35907)
application = <ws4py.server.wsgi.middleware.WebSocketUpgradeMiddleware object at 0x95bc2ac>
127.0.0.1 - - [2012-05-14 17:18:18] "GET /t/example HTTP/1.1" 101 162 0.000933
And, obviously, http://example.localtunnel.local:9999 does not work.
How to fix this? And where I have to modify to change the final subdomain?
Sorry about the creepy english.
Edit
I've followed the paul suggestion and did the downgrading. But although changes have happened, errors still occur. ginkgo process:
$ ginkgo eco.conf.py
Starting process with eco.conf.py...
127.0.0.1 - - [2012-05-22 20:21:11] "GET /t/example HTTP/1.1" 400 116 0.000190
localtunnel process:
$ lt --broker 127.0.0.1:9999 --name example 8000
Traceback (most recent call last):
File "/usr/local/bin/lt", line 9, in <module>
load_entry_point('localtunnel==0.4.0', 'console_scripts', 'lt')()
File "/usr/local/lib/python2.7/dist-packages/localtunnel/client.py", line 31, in main
client.serve_forever()
File "/usr/local/lib/python2.7/dist-packages/ginkgo/core.py", line 188, in serve_forever
self.start()
File "/usr/local/lib/python2.7/dist-packages/ginkgo/core.py", line 124, in start
ready = not self.do_start()
File "/usr/local/lib/python2.7/dist-packages/localtunnel/client.py", line 42, in do_start
self.ws.connect()
File "/usr/local/lib/python2.7/dist-packages/ws4py-0.1.5-py2.7.egg/ws4py/client/threadedclient.py", line 72, in connect
self.process_response_line(response_line)
File "/usr/local/lib/python2.7/dist-packages/ws4py-0.1.5-py2.7.egg/ws4py/client/__init__.py", line 61, in process_response_line
raise HandshakeError("Invalid response status: %s %s" % (code, status))
ws4py.exc.HandshakeError: Invalid response status: 400 Bad Handshake
Although ginkgo does not give any error now, localtunnel still raising errors different from previous errors. Apparently it tries to GET "/t/example" in the connecting process.
Source: (StackOverflow)
I've got an SSH tunnel setup on my macbook, like this...
$ ssh -o ServerAliveInterval=3 -N -L 22222:gitosis-server:22 user@firewall.domain.com
So I can ssh to localhost:22222 and will end up on the gitosis-server behind the firewall.
I've created a local id_rsa.pub file, copied it into the gitosis server(running Centos5), and imported it into gitosis using...
# sudo -H -u gitosis gitosis-init
It was successful as I can see the public key in /var/lib/gitosis/.ssh/authorized_keys.
Back on my macbook I setup a ~/.ssh/config file with the following...
Host gitosis-server
Hostname localhost
HostKeyAlias gitosis-server.domain.com
Port 22222
So...I'm thinking this command should work...
$ git clone gitosis@gitosis-server:gitosis-admin.git
It does not however as it comes up asking for a password....when the public keys should be working.
Initialized empty Git repository in /Users/USER/Development/gitrepo/gitosis-admin/.git/
gitosis@localhost's password:
Any ideas on getting git working through to a gitosis server behind a firewall?
Thanks,
Matt
EDIT - Adding Debug From SSH Attempt
I did this command, 'ssh -vvv gitosis@gitosis-server'. I get some debugging back and it doesn't seem to like my Identity.
debug2: key: /Users/USER/.ssh/id_rsa.gitosis (0x1019b0)
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug3: start over, passed a different list publickey,gssapi-with-mic,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/USER/.ssh/id_rsa.gitosis
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
gitosis@localhost's password:
EDIT 2
OK...Definately a bad key. I double checked all my keys again and of course found the gitosis-server was holding a bad key in the authorized_keys file.
debug1: userauth-request for user gitosis service ssh-connection method none
debug1: attempt 0 failures 0
debug1: PAM: initializing for "gitosis"
debug1: PAM: setting PAM_RHOST to "firewall.domain.com"
debug1: PAM: setting PAM_TTY to "ssh"
debug1: userauth-request for user gitosis service ssh-connection method publickey
debug1: attempt 1 failures 1
debug1: test whether pkalg/pkblob are acceptable
debug1: temporarily_use_uid: 102/103 (e=0/0)
debug1: trying public key file /var/lib/gitosis/.ssh/authorized_keys
debug1: restore_uid: 0/0
debug1: temporarily_use_uid: 102/103 (e=0/0)
debug1: trying public key file /var/lib/gitosis/.ssh/authorized_keys2
debug1: restore_uid: 0/0
Failed publickey for gitosis from FIRE.WALL.IP.ADDRESS port 52453 ssh2
I took a closer look at the authorized_keys file on the gitosis server....and it was incorrect. I double checked the public key file I had copied into /tmp from my workstation and it was the correct one, but different from what was in authorized_keys. I deleted the authorized_keys file on the server and reran the 'sudo -H -u gitosis gitosis-init < /tmp/id_rsa.gitosis.pub'. Checked the authorized_keys file again.....and it was still wrong.
I updated it manually by editing authorized_keys and adding the correct key, and then I got it to work from my workstation through the tunnel for one or two tries. Then it stopped working as before. I went back in to the authorized_keys file on the gitosis server, and sure enough....gitosis had reverted it back to the old key that does not work.
Why is it doing this....reverting back to a bad public key....even after I tried adding it with the above command...which failed to change it....then changed it manually....which worked but git then reverted back to the bad one again.
It's like gitosis keeps remembering the first key I put in there....and won't let me change it to the corrected key.
Frustrating...
Matt
Source: (StackOverflow)
Many Windows MySQL tools like Navicat or EMS have this thing - You just put a PHP file on a shared hosting and can connect local running program to the remote MySQL server on the Web via the web service exposed by that php file.
Are there any good popular free solutions to expose full MySQL as a web service using PHP?
Source: (StackOverflow)
I am trying to figure out how to send data to a server through a proxy. I was hoping this would be possible through tor but being as tor uses SOCKS it apparently isn't possible with httplib (correct me if I am wrong)
This is what I have right now
import httplib
con = httplib.HTTPConnection("google.com")
con.set_tunnel(proxy, port)
con.send("Sent Stuff")
The problem is, it seems to freeze when the tunnel is set. Thanks for your help.
Source: (StackOverflow)
How can I configure TortoiseSVN to connect to a SVN server behind a corporate firewall from home?
This is the question I'm having a hard time finding an answer to. Here's what I DON'T have:
- Official VPN access to the corporate intranet.
- Control over the SVN server.
- Any control over the intranet.
- Cooperation from the IT department.
Here's what I DO have:
- Full control over my computer at my desk at the office.
- Willpower
This is a shot at what I tried, and seem to be unsuccessful at (names of people and places and machines have been changed to protect the innocent):

- I am using Wippien to set up a
zero configuration VPN from my home
computer (NG-ATHOME) to my work computer at my
desk. This works, I have total
network access to and from both
machines.
- I have OpenSSH for Windows running on NG-WORKBOX.
- I have PuTTY on NG-ATHOME connecting to NG-WORKBOX to tunnel dynamically over port 1080. The SOCKS proxy is working, as I can verify that with any web browser. I can confidently say that this is not the problem in the scenario.
- I am using TortoiseSVN on NG-ATHOME configured to use a proxy on 127.0.0.1:1080. When I try to hit "svn://NG-SOURCE/PonyRepository", I get error: cannot connect to host. I can ping NG-SOURCE fine.
Why doesn't SVN work?
Hmm, I have a suspicion that SVN does not like SOCKS. Anyone have a suggestion?
Source: (StackOverflow)
Here is the scenario
I am trying to get scp access to server3, but there is only public ssh access to server 1. To ssh to server3, I have to ssh to server1, ssh to server2, then ssh to server3.
My hopeful end result would be that I could WinSCP to localhost:8022 and it will give me file access to server3.
I am trying to use ssh tunnels, but through all the tutorials and questions I have read none seem to work for this scenario.
I am using putty on Windows.
Any suggestions would be truly helpful. Thank you.
Source: (StackOverflow)
I have a client-server application which use a firebird server 2.5 over internet.
I have met the problem of given a secure access to FB databases and as a first approch a tried to solve this problem by integrating a tunnel solution in the application (STunnel software more exactly). BUT, this approch suffer from many aspects :
- this add more resource consumption (CPU, memory, threads) at both client/server side,
- sotware deployment become a serious problem because STunnel software is writen as a WinNT Service, not a Dll or a Component (WinNT Service need administrator privileges for install)
and my client application need to run without installation !
SO, i decided to take the bull by the horn (or the bird by the feathers as we talk about Firebird). I have downloaded the Firebird 2.5 source code and injected secure tunnelization code directly in his low level communication layer (the INET socket layer).
NOW, encryption/decryption is done directly by the firebird engine for each TCP/IP packet.
What do you think about this approach vs external tunnelization ?
Source: (StackOverflow)
I'd like to use RazorSQL to connect to my database which is running on a remote server. I create a SSH tunnel on my localhost with the following command:
ssh -L 1111:remote.server.com:5432 myuser@remote.server.com
I configure my connection via RazorSQL's GUI, specifying localhost
as the host and 1111
as the port. When I click on "Connect", the following error message appears:
ERROR: An error occurred while trying to make a connection to
the database:
JDBC URL: jdbc:postgresql://localhost:1111/myuser
FATAL:
no pg_hba.conf entry for host "aaa.bbb.ccc.ddd",
user "myuser", database "mydatabase", SSL off
where aaa.bbb.ccc.ddd
is a remote server's IP address.
What is more, I am not allowed to change the contents of my pg_hba.conf
file. That's how it look like at the moment:
# TYPE DATABASE USER CIDR-ADDRESS METHOD
@remove-line-for-nolocal@# "local" is for Unix domain socket connections only
@remove-line-for-nolocal@local all all @authmethod@
# IPv4 local connections:
host all all 127.0.0.1/32 @authmethod@
# IPv6 local connections:
host all all ::1/128 @authmethod@
Is it possible to connect to the database server via SSH tunnel using my current setup and without modifying the server's configuration?
Source: (StackOverflow)
At my workplace, the traffic blocker/firewall has been getting progressively worse. I can't connect to my home machine on port 22, and lack of ssh access makes me sad. I was previously able to use SSH by moving it to port 5050, but I think some recent filters now treat this traffic as IM and redirect it through another proxy, maybe. That's my best guess; in any case, my ssh connections now terminate before I get to log in.
These days I've been using Ajaxterm over HTTPS, as port 443 is still unmolested, but this is far from ideal. (Sucky terminal emulation, lack of port forwarding, my browser leaks memory at an amazing rate...) I tried setting up mod_proxy_connect
on top of mod_ssl
, with the idea that I could send a CONNECT localhost:22 HTTP/1.1
request through HTTPS, and then I'd be all set. Sadly, this seems to not work; the HTTPS connection works, up until I finish sending my request; then SSL craps out. It appears as though mod_proxy_connect
takes over the whole connection instead of continuing to pipe through mod_ssl
, confusing the heck out of the HTTPS client.
Is there a way to get this to work? I don't want to do this over plain HTTP, for several reasons:
- Leaving a big fat open proxy like that just stinks
- A big fat open proxy is not good over HTTPS either, but with authentication required it feels fine to me
- HTTP goes through a proxy -- I'm not too concerned about my traffic being sniffed, as it's ssh that'll be going "plaintext" through the tunnel -- but it's a lot more likely to be mangled than HTTPS, which fundamentally cannot be proxied
Requirements:
- Must work over port 443, without disturbing other HTTPS traffic (i.e. I can't just put the ssh server on port 443, because I would no longer be able to serve pages over HTTPS)
- I have or can write a simple port forwarder client that runs under Windows (or Cygwin)
Edit
DAG: Tunnelling SSH over HTTP(S) has been pointed out to me, but it doesn't help: at the end of the article, they mention Bug 29744 - CONNECT does not work over existing SSL connection preventing tunnelling over HTTPS, exactly the problem I was running into. At this point, I am probably looking at some CGI script, but I don't want to list that as a requirement if there's better solutions available.
Source: (StackOverflow)