Regular Ethernet cable + RPI 2 + Raspbian Jessie Lite 2017-04-10 + Ubuntu 18.04 host
Link the Ethernet cable from your laptop directly to the Pi:
On Ubuntu 17.04 to work around this bug as mentioned on this answer you first need:
sudo apt-get install dnsmasq-base
Then open the network manager:
+ sign (Add a new connection)
- IPv4 Settings
- Method: Shared to other computers
- Set a good name for it
Find the IP of the Pi on host:
outputs something like:
1532204957 b8:27:eb:0c:1f:69 10.42.0.160 raspberrypi 01:b8:27:eb:0c:1f:69
10.42.0.160 is the IP, then as usual:
I also have the following in my
piip() ( cat /var/lib/misc/dnsmasq.leases | cut -d ' ' -f 3; )
pissh() ( sshpass -p raspberry ssh "pi@$(piip)"; )
From inside the Pi, notice that it can access the internet normally through your host's other interfaces:
For example on my laptop, the Pi takes up the Ethernet, but the host is also connected to the internet through WiFi.
The crossover cable is not required if the host network card supports Auto MDI-X. This is the case for most recent hardware, including for example the 2012 Lenovo T430 I tested with, which has an "Intel® 82579LM Gigabit Network Connection" which documents support for Auto MDI-X.
Now you can also:
This is a more concise version of: http://www.interlockroc.org/2012/12/06/raspberry-pi-macgyver/ which was mentioned by: https://raspberrypi.stackexchange.com/a/4294/33424
Serial to USB cable
Another alternative if you just want to get a shell on the Pi, is to use a serial cable.
This does not use SSH or networking itself, but rather the older, simpler, more direct, more reliable, lower bandwidth, lower distance serial interface. The Pi won't have access to the Internet with this method.
You just need a cheap serial to USB connector like this one: https://thepihut.com/products/adafruit-usb-to-ttl-serial-cable-debug-console-cable-for-raspberry-pi
Then, you attach the sockets to the corresponding GPIO serial pins (TX, RX, 5V and ground)
as documented at: https://www.raspberrypi.org/documentation/usage/gpio/README.md
Finally, plug the USB side of the connector to your host computer, and get a shell with:
sudo apt install screen
sudo usermod -a -G dialout $USER
screen /dev/ttyUSB0 115200
Desktop computers still have a serial port which you can connect directly wire to wire with the Pi, but these are hidden in most laptops, and then we need the USB adaptor, see also: https://unix.stackexchange.com/questions/307390/what-is-the-difference-between-ttys0-ttyusb0-and-ttyama0-in-linux/367882#367882
Here is a video by Adafruit showing it: https://www.youtube.com/watch?v=zUBPeoLW16Q