Thinking Out Loud

March 11, 2013

port forwarding with plink

Filed under: linux,oracle — mdinh @ 4:07 am
Plink (a command-line interface to the PuTTY back ends)
C:\Users\dinh>plink
PuTTY Link: command-line connection utility
0.62 x64 Built by Tad DeVries http://splunk.net
Usage: plink [options] [user@]host [command]
       ("host" can also be a PuTTY saved session name)
Options:
  -V        print version information and exit
  -pgpfp    print PGP key fingerprints and exit
  -v        show verbose messages
  -load sessname  Load settings from saved session
  -ssh -telnet -rlogin -raw -serial
            force use of a particular protocol
  -P port   connect to specified port
  -l user   connect with specified username
  -batch    disable all interactive prompts
The following options only apply to SSH connections:
  -pw passw login with specified password
  -D [listen-IP:]listen-port
            Dynamic SOCKS-based port forwarding
  -L [listen-IP:]listen-port:host:port
            Forward local port to remote address
  -R [listen-IP:]listen-port:host:port
            Forward remote port to local address
  -X -x     enable / disable X11 forwarding
  -A -a     enable / disable agent forwarding
  -t -T     enable / disable pty allocation
  -1 -2     force use of particular protocol version
  -4 -6     force use of IPv4 or IPv6
  -C        enable compression
  -i key    private key file for authentication
  -noagent  disable use of Pageant
  -agent    enable use of Pageant
  -m file   read remote command(s) from file
  -s        remote command is an SSH subsystem (SSH-2 only)
  -N        don't start a shell/command (SSH-2 only)
  -nc host:port
            open tunnel in place of session (SSH-2 only)
  -sercfg configuration-string (e.g. 19200,8,n,1,X)
            Specify the serial configuration (serial only)

Configuration:

Oracle RDBMS on Virtual Box using NAT(eth0) and Host Only Networking(eth1) listening on port 1531.

Windows7 Host:

Ethernet adapter VirtualBox Host-Only Network:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : VirtualBox Host-Only Ethernet Adapter
   Physical Address. . . . . . . . . : 08-00-27-00-8C-10
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::84bc:48b3:8e40:e0d1%42(Preferred)
   Autoconfiguration IPv4 Address. . : 169.254.224.209(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Default Gateway . . . . . . . . . :
   DHCPv6 IAID . . . . . . . . . . . : 638058535
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-18-87-4B-A4-D4-BE-D9-60-5A-3F
   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   NetBIOS over Tcpip. . . . . . . . : Enabled

OEL 6.3 Guest:

[oracle@lax:db01]/home/oracle
$ ifconfig -a
eth0      Link encap:Ethernet  HWaddr 08:00:27:CC:FF:D7
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fecc:ffd7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:74 errors:0 dropped:0 overruns:0 frame:0
          TX packets:95 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:24907 (24.3 KiB)  TX bytes:9397 (9.1 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:2C:2E:24
          inet addr:169.254.224.210  Bcast:169.254.255.255  Mask:255.255.0.0
          inet6 addr: fe80::a00:27ff:fe2c:2e24/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1049 errors:0 dropped:0 overruns:0 frame:0
          TX packets:853 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:157877 (154.1 KiB)  TX bytes:150602 (147.0 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2206 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2206 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:331342 (323.5 KiB)  TX bytes:331342 (323.5 KiB)

LISTENER port 1531

[oracle@lax:db01]/home/oracle
$ lsnrctl status listener_db01

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 10-MAR-2013 20:29:52

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=lax.localdomain)(PORT=1531)(SEND_BUF_SIZE=32767)(RECV_BUF_SIZE=32767)))
STATUS of the LISTENER
------------------------
Alias                     listener_db01
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                10-MAR-2013 19:56:07
Uptime                    0 days 0 hr. 33 min. 44 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.3/db_1/network/admin/listener.ora
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lax)(PORT=1531)))
Services Summary...
Service "lax_db01" has 2 instance(s).
  Instance "db01", status UNKNOWN, has 1 handler(s) for this service...
  Instance "db01", status READY, has 1 handler(s) for this service...
The command completed successfully

Port forwarding – connecting to server using IP address: 169.254.224.210

C:\Users\dinh>plink -batch -v -x -a -T -C -noagent -ssh -L 127.0.0.1:1521:169.254.224.210:1531 oracle@169.254.224.210 -pw oracle
Looking up host "169.254.224.210"
Connecting to 169.254.224.210 port 22
Server version: SSH-2.0-OpenSSH_5.3
Using SSH protocol version 2
We claim version: SSH-2.0-PuTTY_Local:_Dec_15_2011_21:59:21
Server supports delayed compression; will try this later
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-256
Host key fingerprint is:
ssh-rsa 2048 0f:4f:4c:21:99:0a:41:f3:bf:28:8c:e2:c9:1c:45:f6
Initialised AES-256 SDCTR client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised AES-256 SDCTR server->client encryption
Initialised HMAC-SHA1 server->client MAC algorithm
Using username "oracle".
Using SSPI from SECUR32.DLL
Attempting GSSAPI authentication
GSSAPI authentication request refused
Sent password
Access granted
Initiating key re-exchange (enabling delayed compression)
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-256
Initialised AES-256 SDCTR client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised zlib (RFC1950) compression
Initialised AES-256 SDCTR server->client encryption
Initialised HMAC-SHA1 server->client MAC algorithm
Initialised zlib (RFC1950) decompression
Opened channel for session
Local port 127.0.0.1:1521 forwarding to 169.254.224.210:1531
Started a shell/command
Opening forwarded connection to 169.254.224.210:1531
Nothing left to send, closing channel
Forwarded port closed
Opening forwarded connection to 169.254.224.210:1531
Nothing left to send, closing channel
Forwarded port closed
^C

Port forwarding – connecting to server using PuTTY Saved Session: vm-lax_db01

Note: the IP address of the server used to forward port still needs to be listed unless the IP is added to hosts file.

C:\Users\dinh>plink -v -x -a -T -C -noagent -ssh -L 127.0.0.1:1521:169.254.224.210:1531 oracle@vm-lax_db01 -pw oracle
Looking up host "169.254.224.210"
Connecting to 169.254.224.210 port 22
Server version: SSH-2.0-OpenSSH_5.3
Using SSH protocol version 2
We claim version: SSH-2.0-PuTTY_Local:_Dec_15_2011_21:59:21
Server supports delayed compression; will try this later
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-256
Host key fingerprint is:
ssh-rsa 2048 0f:4f:4c:21:99:0a:41:f3:bf:28:8c:e2:c9:1c:45:f6
Initialised AES-256 SDCTR client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised AES-256 SDCTR server->client encryption
Initialised HMAC-SHA1 server->client MAC algorithm
Using username "oracle".
Using SSPI from SECUR32.DLL
Attempting GSSAPI authentication
GSSAPI authentication request refused
Sent password
Access granted
Initiating key re-exchange (enabling delayed compression)
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-256
Initialised AES-256 SDCTR client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised zlib (RFC1950) compression
Initialised AES-256 SDCTR server->client encryption
Initialised HMAC-SHA1 server->client MAC algorithm
Initialised zlib (RFC1950) decompression
Opened channel for session
Local port 127.0.0.1:1521 forwarding to 169.254.224.210:1531
Started a shell/command
Opening forwarded connection to 169.254.224.210:1531
Nothing left to send, closing channel
Forwarded port closed

Connect using SQL*Plus

C:\Users\dinh>sqlplus mdinh/mdinh@127.0.0.1:1521/lax_db01

SQL*Plus: Release 11.2.0.1.0 Production on Mon Mar 11 00:00:14 2013

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
db01

SQL> select db_unique_name from v$database;

DB_UNIQUE_NAME
------------------------------
lax_db01

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
About these ads

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Rubric Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 301 other followers

%d bloggers like this: