linux - Network Register a Headless Device

06
2014-04
  • nitsujri

    I have a Raspberry Pi (but also applies to any headless machine). I SSH into the machine, but I can't go anywhere else unless I share my internet with it via OS X.

    To use the internet, each device has to enter a username/password through a webform.

    What are the recommended ways to performing this?

  • Answers
  • MariusMatutiae

    I would be surprised this question has not been asked before...

    In any case: the basic command is:

       curl --user name:password http://IP_address_of_thecaptivePortal -v
    

    (the -v option, for verbose, is useful since you are doing this for the first time). However, it may prove useful to allow cookies,

       curl -b cookies.txt -c cookies.txt --data "Username=xx&Password=xx&Login=Login" http://IP_address_o_the_captive_portal
    

    Keeping cookies will allow you to appear as registered already at your next request.

  • zachzins

    As an alternative to curl, you could use a terminal-based web browser. There are a few of them, but I would suggest Lynx.

    The main issue with this is that you'll have to find a way to install it. You could find a temporary Internet connection somewhere else to do this.

    To install it you can run something similar to sudo apt-get install lynx.

    To run Lynx you can run lynx -accept_all_cookies http://(webform address). You can then use the up and down arrows to highlight links on the page. The right arrow will follow the link that is highlighted and the left arrow goes to the previous page. Control/Command + C exits the browser.


  • Related Question

    windows - Enable networking on raspberry pi - Internet sharing with Win7
  • Kyle

    I do not have physical access to the wireless router that I use (shared living agreement), so I cannot connect my RasPi (Model B) to the router via Ethernet. However, I am running a Windows 7 64-bit machine that connects over WiFi and has an unused Ethernet port.

    I've set up Internet sharing and bound the Ethernet port to be the device that shares the Internet, and I'm running Debian Wheezy (2012-07-15 build) on my RasPi on an 8 GB SD card. However, when I plug the Ethernet cable into the RasPi and my local Win7 box, nothing seems to work on the RasPi side.

    I get tx/link lights on my Windows machine as well as the RasPi, but when I run ifconfig, I get eth0 with 12 tx packets, 0 errors, 0 dropped, etc - and no IP bound to it.

    I've tried editing /cat/networking/interfaces and tried to enable eth1-9 (this seems to be a weird bug that some users report where eth0 isn't the properly bound device), but all fail when I do sudo /etc/init.d/networking restart except eth0.

    Google has failed me so far - what's the next step in getting wired/shared Internet working? Bridging the devices on the Windows machine?

    Thanks!


  • Related Answers
  • Kyle

    Figured it out - I had to edit /etc/network/interfaces with this info:

    auto lo eth0
    iface lo inet loopback
    iface eth0 inet dhcp
    

    The first line by default was auto lo, so I added the eth0 and restarted the networking services and it worked perfectly!