Author: Superhero Ninja

  • Can not connect to Virtualbox Guest Oracle Database 12c Developer Day Database VM due to Oracle Linux firewall

    It seems there’s a firewall present on the latest Developer Days Database image which I’ve just downloaded from Oracle.

    Description:

    I enjoy using these images because it is a complete reference install of Oracle Linux, Oracle Database and Oracle SQL Developer (among others). Besides that, it only takes 10 minutes to setup a base install from the image.
    Usually I like to connect from my local SQL Developer instead of the one inside the VM.

    Problem:

    But with this setup I could not connect when I added the NAT Port Forwarding in Virtualbox, it timed out when trying to connect. I could connect from the SQL Developer inside the VM, just not through the NAT port which was forwarded (important: see the bottom of this post to check the NAT Port Forwarding settings in Virtualbox)

    Solution:

    It’s fairly easy to add a firewall rule which allows access to port 1521 on Oracle Linux, we can even do it with a GUI:
    Select Menu “System” – “Administration” – “Firewall”
    Screenshot from 2014-08-19 12:55:14Then follow these steps:

    1. Click [Other Ports]
    2. Click [Add]
    3. Select [User Defined]
    4. Enter Port: “1521”
    5. Select Protocol: “TCP”
    6. Click [Apply]
    7. Click [Reload]

    Screenshot from 2014-08-19 12:55:55
     
    You’ve just added port 1521 to the iptables which makes it okay to connect to this port from another IP outside the local machine.
    We can test from SQL Developer, running on the Host:
    Oracle SQL Developer : Local - Sys_009
     
    And it works! 🙂
     

    Extra: NAT Port Forwarding in Virtualbox

    Just to be sure, these are the settings you’ll need to set inside the Virtualbox Manager to setup the port forwarding on port 1521 from the guest to the host:
    Select the “Settings” of the Developer Day VM and then:

    1. Select “Network”
    2. Click [Port Forwarding]

    OTN Developer Day VM_1 - Settings_012
     
    Then in the Port Forwarding Rules:

    1. Enter a descriptive name: “DB”
    2. Enter the host port: “1521”
    3. Enter the guest port: “1521”

    OTN Developer Day VM_1 - Settings_011
     

  • Oracle SQL Developer 4 does not run on Oracle Java 7 on Ubuntu 14.04

    Wow, ain’t this awkward :-). I cannot run Oracle SQL Developer 4 (4.0.2) on Ubuntu with Oracle JDK 7..

    To be complete: when running SQL Developer with JDK 7 from Oracle itself, displays the following error;

    joris@dipshit:~/programs/sqldeveloper$ ./sqldeveloper.sh
    Oracle SQL Developer
    Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    LOAD TIME : 968#
    # A fatal error has been detected by the Java Runtime Environment:
    #
    # SIGSEGV (0xb) at pc=0x6aa69be0, pid=9537, tid=1836366656
    #
    # JRE version: Java(TM) SE Runtime Environment (7.0_65-b17) (build 1.7.0_65-b17)
    # Java VM: Java HotSpot(TM) Server VM (24.65-b04 mixed mode linux-x86 )
    # Problematic frame:
    # C 0x6aa69be0
    #
    # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
    #
    # An error report file with more information is saved as:
    # /home/joris/programs/sqldeveloper/sqldeveloper/bin/hs_err_pid9537.log
    #
    # If you would like to submit a bug report, please visit:
    # http://bugreport.sun.com/bugreport/crash.jsp
    #
    /home/joris/programs/sqldeveloper/sqldeveloper/bin/../../ide/bin/launcher.sh: line 1193: 9537 Aborted (core dumped) ${JAVA} "${APP_VM_OPTS[@]}" ${APP_ENV_VARS} -classpath ${APP_CLASSPATH} ${APP_MAIN_CLASS} "${APP_APP_OPTS[@]}"

    Solution: Run Oracle SQL Developer with OpenJDK

    First we’ll need to install OpenJDK:

    sudo apt-get install openjdk-7-jdk 

    Then we’ll need to change the path which SQL Developer uses. This was asked once when you first started it and it is saved in the following path:

    ~/.sqldeveloper/4.0.0/product.conf

    The file [[ product.conf ]] contains the value SetJavaHome, we need to change this to the OpenJDK path;

    If you're running 32 bit Ubuntu:

    SetJavaHome /usr/lib/jvm/java-7-openjdk-i386

    Or if you're running 64 bit Ubuntu:

    SetJavaHome /usr/lib/jvm/java-7-openjdk-amd64

    After saving this change, you can start SQL Developer on Ubuntu 14.04 and it will use OpenJDK 7, without changing your regular Java settings!

  • SSH: Different settings (keys!) for different hosts

    There’s a simple way to create aliases in a SSH config file. This way you can connect way easier to different hosts, combined with this blog post to use keys to log in.
    Where you used to use this connect string:

    ssh [email protected]
    [email protected]'s password: <<enter boresome password>>

    You can now just enter

    ssh pi

    Where “pi” is the alias that you’ll be using!
    The only thing you’ll need to do is create the following file:
    [[ ~/.ssh/config ]]

    Host pi
      HostName 192.168.0.5
      User pi
      << (!) Only add below line if you're using keys to log in >>
      IdentityFile ~/.ssh/keys/raspberry_key

    Aint that awesome!?
    Ps. If you’re still being asked to enter your password, check your keys and please look at this blog post I wrote.
     

  • Suspend in Gnome 3

    I was searching for the suspend button in Gnome 3 and could not find it, even though I knew it was enabled when I logged into Unity and was able to suspend the same laptop..!
    Appearently it is hidden (a bit).
    This is the top right menu in Gnome 3 by default (without suspend options)
    Screenshot from 2014-08-11 13:43:44
    If you press “alt” while this menu is open, it will show the suspend button (with the pause icon):
    Screenshot from 2014-08-11 13:44:22
    So now I can suspend my laptop again!
    Happy energy savings! 🙂
     

  • SSH without password

    SSH is one of the most friendly deamons in the Linux toolbox, you can port forward your home server, you can surf the internet via your own proxy server, you can transfer files, it’s the first thing I set up on a freshly installed box and by far the most used service around my home (yeah, that’s nerdy) 🙂
    This post will outline how you can create a public and private RSA key pair, and then we will use that key pair to authenticate ourselves to another computer in the network.
    We will need to complete the following steps:

    1. Create a public/private rsa key pair
    2. Copy the public key to the remote host via ssh-copy-id
    3. Login to the remote system without a password

    Create a public/private rsa key pair

    If you haven’t created a rsa key pair yet, we can create it with this command:

    ssh-keygen

    As shown in this screenshot:
    Screenshot from 2014-07-28 21:28:18If you have previously created a key pair, you will be asked to replace this.
    For my home machines I don’t use a passphrase, if you’re more paranoid (or careful) you can do so. Please read this article for more info on passphrases and how to use them.
    The keys have been generated in /home/yourloginname/.ssh and are called id_rsa and id_rsa.pub.
    Never, never send someone your private (id_rsa) key! That is the same as handing over your house keys..

    Copy the public key to the remote host via ssh-copy-id

    This step should be repeated for all hosts to which you want to SSH with the newly created RSA key pair.
    The command used is:

    ssh-copy-id -i ~/.ssh/id_rsa [email protected]

    Screenshot from 2014-07-28 21:30:35
     
    You will need to enter your password one last time, after that your public key is added to the authorized_keys file, which is automatically created on the target system.
    After this step you don’t need to use a password any more!

    Login to the remote system without a password

    Just SSH into the remote system:
    Screenshot from 2014-07-28 21:32:01
    And wonder what you’re gonna do with all that extra time you’ve just won because entering passwords belongs to the past… 🙂
     
     

  • CHere Bash Here without Admin Rights – CYGWIN

    I wanted to add a “Bash Here” context entry when I right click on a directory:
    Screenshot - 28-2-2014 , 13_01_20
    This Bash Here would open that directory in Cygwin (mintty).
    My current PC is fairly regulated, so without admin rights and thus I can’t use the CHere option which I would normally use.
    I just created the registry keys via regedit and that works fine.
    You can use two options:

    1. Import the registry file mentioned below
    2. Create the keys yourself

    1. Import the registry file

    Create a file called cygwin_bash_here.reg with the following contents:

    Windows Registry Editor Version 5.00
    [HKEY_CURRENT_USER\Software\Classes\Directory]
    [HKEY_CURRENT_USER\Software\Classes\Directory\shell]
    [HKEY_CURRENT_USER\Software\Classes\Directory\shell\bashhere]
    @="Bash Here"
    [HKEY_CURRENT_USER\Software\Classes\Directory\shell\bashhere\command]
    @="C:\\cygwin\\bin\\mintty.exe"

    Save the file and double click on it to import it to the registry.

    2. Create the keys yourself

    1. Open the registry editor: Start – Run – “regedit”
    2. Open the following path: HKEY_CURRENT_USER\Software\Classes
    3. Create key: “Directory”
    4. Inside Directory, create key: “shell”
    5. Inside shell, create key: “bashhere”
    6. Inside bashhere double click on the standard key and insert text “Bash here” without quotes (This is the text which is displayed in the context menu.
    7. Inside bashhere, create key: “command”
    8. Inside command, double click on the standard key and insert text “C:\cygwin\bin\mintty.exe” without quotes. Important: This is the command which is run. Please change directory to your cygwin directory

    Screenshot - 28-2-2014 , 13_16_02

    Conclusion

    Both options will create a context menu item which opens Cygwin at your current windows directory!

  • Cygwin – Your group is currently mkpasswd

    This message occurs every time you start your freshly installed Cygwin when you’re logged in as a domain user.

    Your group is currently "mkpasswd".  This indicates that your
    gid is not in /etc/group and your uid is not in /etc/passwd.
    The /etc/passwd (and possibly /etc/group) files should be rebuilt.
    See the man pages for mkpasswd and mkgroup then, for example, run
    mkpasswd -l [-d] >> /etc/passwd
    mkgroup  -l [-d] >> /etc/group
    Note that the -d switch is necessary for domain users.

    Important: You need to install Cygwin with the user you are logged in with.
    Tip
    : Remove the word “setup” from the cygwin executable to be able to install it without administrator privileges. (e.g. setup-x64.exe should be renamed to cygwin-x64.exe)

    • mkpasswd -l only shows my local users, and not the domain user I’m logged in with, so that does not solve this.
    • mkpasswd -l -d get an enormous amount of users because it tries to replicate my whole organisation, which is not necessary.

    We just need our current user ( mkpasswd -c ) to be sent to the /etc/passwd and /etc/group files, to do this, we use this command:

    Solution:

    mkpasswd -c >> /etc/passwd
    mkgroup -c >> /etc/group

    After that, our current account is added to both /etc/passwd and /etc/group and the annoying greeting message is gone!

  • Oracle SQL – BLOB to XML Type ( ORA-06502 PL/SQL : numeric or value error : raw variable length too long )

    I am working with a database schema where xml content is being stored in a BLOB and I’m working on querying that XML.
    When you cast the BLOB to VARCHAR, you’ll run into the limit of 2000 characters with the following error:

    ORA-06502 PL/SQL : numeric or value error : raw variable length too long

    So this trick came in handy:

    SELECT XMLTYPE( BLOB_FIELD, 871 ) AS AWESOMEXML FROM YOUR_TABLE;

    Please be very aware of the character set that you are using, you can enter a world of hurt when you’re using the wrong one. The number 871 is the character set UTF8, which we are using.
    For other character sets, check http://www.mydul.net/charsets.html

  • SSH through a proxy to a remote server

    I wanted to SSH into my home server from my workplace but I couldn’t reach it directly because of the way the network was set up.
    As it turns out it is quite easy to do by using the corkscrew program.
    Edit ~/.ssh/config and add the following lines:

    Host home joris.his.homeserver.com
        Hostname joris.his.homeserver.com
        User joris
        ProxyCommand corkscrew proxyserveraddress proxyserverport %h %p

    The most important part is the ProxyCommand, this lets your ssh client know that it should use corkscrew as a proxy to your host. %h means the host of your remote server, %p means the port of your remote server.

  • Authentication – Subversion on command line will not remember credentials

    I ran into this issue today on my command line SVN client.
    Every time I ran the SVN command against my repository, it asks for my password. It does remember the username but doesn’t store the password.
    There are a couple of settings to check in two different files:

    • .subversion/config
    • .subversion/servers

    .subversion/config

    The config file contains a setting which sets the password store you will be using. We need to disable all password stores and use an empty list, which is done by uncommenting (or adding) the next line

    password-stores =

    .subversion/servers

    The servers file contains settings which allow you to save your passwords in general and to save the passwords in plaintext (please be careful when choosing this option!)
    This file is divided in sections which are set with the [] brackets. In the [global] group you should uncomment (or add) the following lines:

    store-passwords = yes
    store-plaintext-passwords = yes