How to enter internet credentials using terminal? After attaching the ethernet cable to my Mac I need to enter username and password to access the Internet:

 

The problem is that I would like to perform a system recovery using cmd+R at startup. There I need Internet, but I don't get any dialog which suggests me to enter my credentials. 

Is it possible to enter the credentials using Terminal.app? Or does a better method exist to solve this?

I have MacBook Pro 2012 with El Capitan installed.
The short answer is "Yes."  You can enter your credentials within Terminal.  You have to use the networksetup command

That's if you can get to terminal...  If you can, then the following will help get you connect.  But, if you can't, scroll down the bottom for an alternate...

However, you have to have a create an 802.1x profile for which to connect to your network.  This is as straight forward as just entering in a username/password  

Here is the man page for the networksetup command on Apple's website: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/networksetup.8.html  You can view this in Terminal by typing man networksetup

Since you mentioned plugging in your Ethernet, it's safe to assume you are using 802.1X Port Based Authentication.  Basically, there is a server, most likely a RADIUS server, but possibly another type of  AAA server (authentication, authorization, and accounting) that allows your computer onto the network.  

Basically, before you are allowed to go anywhere, the network is checking to see if your device is authorized to connect, to where you can go, and (who/what) should be charged (if applicable).

So, how do you set this up?

This can get a little complex, so normally the IT department will supply you with a config file for you to import.  You would do so with the command networksetup -import8021xProfiles Ethernet &lt;filename of profile to import&gt;

From what I have seen, you need OS X Server to create the profile, however, it is not hard to edit one once it has been created.  Here's a link to one created for the SMU network:  https://blog.iphoting.com/blog/archives/817-Lion-Wireless-Access-in-SMU.html

Disclaimer:  Don't expect SMU's profile to work in your environment.  It is most likely configured completely different than what your environment is configured for.

Alternate Method

Use another computer and share the Internet Connection

You can use virtually any other computer (Apple, Windows, Linux) to connect to your institutions network whether it be wireless or wired.  Once you have that computer up and running, just share the Internet connection.

Since this is an Apple thread, you can use this example as a basis for sharing Internet.  The connection is WiFi, but it is exactly the same for Ethernet.

If both your computers are connected to Ethernet, you will need a USB to Ethernet adapter and a crossover cable (or a switch).  The onboard Ethernet on the working computer will go to the institution network, the USB to Ethernet adapter will go to the computer you are trying to connect.

Once you have the working computer function, you turn on Internet sharing which effectively turns it into a router.  You can then connect to the Internet on the computer you are trying to boot into recovery mode.