Difference between revisions of "Connecting to the Pi"

From Bike Wiki
Jump to navigation Jump to search
(content)
 
(26 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Here's how to connect to the Pi.
+
Here's how to connect to the Pi. Note that in all cases, the Pi's username is <code>pi</code>; the password is <code>raspberry</code>; and the answer to "Are you sure you want to continue connecting?" is always "yes".
  
== Ad hoc ==
+
== General notes ==
 +
The Pi can be configured to create its own ad-hoc wifi network called RPiwireless, or to connect to the LocomotionLab wifi network in Upson 566 (for Internet access).
 +
 
 +
To configure it, you must first be connected to the Pi. If you can't ssh in at all, you can connect a keyboard and display using the Pi's USB and HDMI ports.
 +
 
 +
Make sure you have set up the Pi. Otherwise, rPIwireless will not show up. If you do not know how to set up the Pi, read [[Setting up the Pi]].
 +
 
 +
* To switch to RPiwireless: <code>sudo cp /etc/network/interfaces-adhoc /etc/network/interfaces</code>
 +
* To switch to LocomotionLab: <code>sudo cp /etc/network/interfaces-wifi /etc/network/interfaces</code>
 +
 
 +
'''Reboot the Pi afterwards to apply any changes.'''
 +
 
 +
If you've switched to LocomotionLab, ssh in using <code>ssh pi@10.0.1.50</code>.
 +
 
 +
== Ad hoc (RPiwireless) ==
  
 
=== OS X ===
 
=== OS X ===
  
Connect to RPiwireless from the WiFi dropdown menu, then <code>ssh pi@192.168.1.1</code>. Doesn't work? Try <code>arp -a</code> at a terminal. If an IP address associated with the hostname <code>pehuen-pi</code><ref>Pehuen Moure is a past member of the team</ref> comes up, use that in the SSH command instead. Otherwise, keep trying 192.168.1.1 (192.168.2.2 sometimes works).
+
* Connect to RPiwireless from the WiFi dropdown menu (warning: you (normally) won't be able to access the internet after you do this).
 +
* At a terminal, run <code>ssh pi@192.168.1.1</code>.
 +
** The answer to "Are you sure you want to continue connecting?" is "yes"
 +
** The password is <code>raspberry</code>.
 +
* If that didn't work, try <code>arp -a</code> at a terminal.
 +
** If an IP address associated with the hostname <code>pehuen-pi</code><ref>Pehuen Moure was on the team in (at least) 2017</ref> comes up, use that in the SSH command instead.
 +
* Otherwise, keep trying 192.168.1.1 (192.168.2.2 sometimes works).
 +
 
 +
=== Dylan's laptop ===
 +
 
 +
Disconnect from all WiFi networks. Open the program Windows Powershell from the Start menu. In the terminal that appears, run <code>netsh wlan connect RPiwireless</code>.
 +
 
 +
If that worked, the laptop should now be connected to RPiwireless, and complain about no Internet access. This is sensible, since the Pi doesn't have any other way to connect to the Internet.
 +
 
 +
You may now use an SSH client (either PuTTY or MobaXterm) to connect to pi@192.168.1.1. Not sure which one to use? MobaXterm is easier; open the program using the shortcut on the desktop, then click "New Session", select "SSH", enter 192.168.1.1 as the IP and <code>pi</code> as the username, then connect.
  
 
=== Arch Linux ===
 
=== Arch Linux ===
Line 15: Line 43:
 
First, make sure your network interface (i.e. network card) doesn't have anything running on it. In the examples below, <code>dev wlp4s0</code> is used as the name of the interface. If your interface name is different (get the interface name with <code>iw dev</code>, and it'll be after the word "Interface"), replace as necessary. If you use netctl, the following command will stop the current connection:
 
First, make sure your network interface (i.e. network card) doesn't have anything running on it. In the examples below, <code>dev wlp4s0</code> is used as the name of the interface. If your interface name is different (get the interface name with <code>iw dev</code>, and it'll be after the word "Interface"), replace as necessary. If you use netctl, the following command will stop the current connection:
  
    netctl stop $(netctl list | grep '^\*' | cut -d'*' -f2)
+
netctl stop $(netctl list | grep '^\*' | cut -d'*' -f2)
  
 
Now, while your interface is down, change it over to IBSS (the type for ad-hoc data):
 
Now, while your interface is down, change it over to IBSS (the type for ad-hoc data):
  
    iw dev wlp4s0 set type ibss
+
iw dev wlp4s0 set type ibss
 +
 
 +
And bring the interface up:
 +
 
 +
ip link set wlp4s0 up
  
 
After that, join the ad-hoc network. '''Replace ''FREQUENCY''''' with an actual frequency. Choose the frequency from [https://en.wikipedia.org/wiki/List_of_WLAN_channels#2.4_GHz_(802.11b/g/n/ax) this table]. You'll probably use 2.4 GHz (802.11b/g/n/ax) channels 1 or 2, which are 2412 and 2417 MHz respectively, so you would replace ''FREQUENCY'' with <code>2412</code> or <code>2417</code>.
 
After that, join the ad-hoc network. '''Replace ''FREQUENCY''''' with an actual frequency. Choose the frequency from [https://en.wikipedia.org/wiki/List_of_WLAN_channels#2.4_GHz_(802.11b/g/n/ax) this table]. You'll probably use 2.4 GHz (802.11b/g/n/ax) channels 1 or 2, which are 2412 and 2417 MHz respectively, so you would replace ''FREQUENCY'' with <code>2412</code> or <code>2417</code>.
  
    iw dev wlp4s0 ibss join RPiwireless ''FREQUENCY''
+
iw dev wlp4s0 ibss join RPiwireless ''FREQUENCY''
  
 
Now, register an IP address: (I haven't figured out if this next command is strictly necessary)
 
Now, register an IP address: (I haven't figured out if this next command is strictly necessary)
  
    ip addr add 192.168.1.2/255.255.255.0 dev wlp4s0
+
ip addr add 192.168.1.2/255.255.255.0 dev wlp4s0
  
 
And try to connect: (you may have to wait a minute or so before this starts working)
 
And try to connect: (you may have to wait a minute or so before this starts working)
  
    ssh pi@192.168.1.1
+
ssh pi@192.168.1.1
 +
 
 +
The username (the <code>pi@</code> part) is important because otherwise ssh may try to use your current username, which will almost certainly not be <code>pi</code>.
 +
 
 +
Warning! The ssh connection produced by this method is almost unusably slow at times. I (Daniel, April 2019) am trying to fix this. I hypothesize you may be able to switch the channel on the Pi side (by editing the "channel" specified in <code>/etc/network/interfaces</code>) to avoid interference.
 +
 
 +
=== Windows 10, newer laptops ===
 +
 
 +
First, open Powershell and run <code>netsh wlan show wirelesscapabilities</code>, then look for a line that says "IBSS". It'll either say "Supported" or "Not Supported".
 +
 
 +
If it says "Not Supported", your current driver doesn't support ad-hoc networks. Microsoft has deprecated ad-hoc IBSS, which is a fancy name for ad-hoc networks of the type discussed on this page. So, you'll need an old driver that supports ad-hoc IBSS, as well as the hardware to run it on. I don't think newer laptops support this. For more information on which hardware supports this, [https://www.intel.com/content/www/us/en/support/articles/000023257/network-and-i-o/wireless-networking.html Intel has a list]. (Check which network device you have by going to Device Manager, selecting "Devices by type" under the "View" menu, and looking for something that looks like it should be a wireless adapter.) For a potential workaround, see [https://superuser.com/a/1299163 this Super User answer].
 +
 
 +
If you end up with IBSS being supported, you'll want to open network settings, open the Wi-Fi menu, click "Manage known networks", and then "Add a new network". Enter RPiwireless for the name, keep the security as "Open", and leave both checkboxes unchecked. Now, in Powershell:
 +
 
 +
netsh wlan set profileparameter RPiwireless connectiontype=ibss
 +
 
 +
It might give you this error:
 +
 
 +
Failed to modify the profile. Error 0x8000D: The BSS type is not valid.
 +
 
 +
In which case your hardware and/or driver doesn't support ad-hoc IBSS.
 +
 
 +
If it worked, though, you can connect to the Pi's network using:
 +
 
 +
netsh wlan connect RPiwireless
 +
 
 +
Now, the Pi doesn't have DHCP, so you'll need to assign it an IP manually. Try DHCPwiz. After that, DHCPwiz will give you an IP address, and then you can use PuTTY or MobaXterm to connect to <code>pi@</code> the Pi's IP address.
 +
 
 +
Further reading: [https://globalcache.zendesk.com/hc/en-us/articles/114094165352-FAQ-Windows-8-1-and-Windows-10-AdHoc-network-support-solution this page on connecting to ad-hoc networks using Windows 8.1 or 10]
 +
 
 +
== Ethernet ==
 +
=== Windows ===
 +
Connect your computer and the Pi using an Ethernet cable. Make sure "Unidentified network (no internet)" or something similar is showing up in your list of networks. Now, [http://www.dhcpserver.de/cms/download/ download dhcpwiz] (the download is called "DHCP Server" but contains the dhcpwiz executable). Version 2.5.2 works on Windows 10 as of April 2019. Extract the zip file to anywhere, and run the dhcpwiz executable. Now:
 +
 
 +
# On the '''Welcome''' screen, click Next.
 +
# On '''Network Interface cards''', select "Ethernet". Make sure the IP Address listed for it isn't 0.0.0.0. If "Ethernet" doesn't show up or displays with 0.0.0.0, click "Refresh" periodically until it's fine. Click Next.
 +
# On '''Supported Protocols''', check the boxes for HTTP and DNS. Click Next.
 +
# On '''Configuring DHCP for Interface''', just click Next.
 +
# On '''Writing the INI file''', check the "Overwrite existing file" checkbox, then click the "Write INI file" button. Click Next.
 +
# On '''DHCP configuration completed''', check the "Run DHCP server immediatly" checkbox, and click Finish.
 +
# On '''DHCP Server''', click "Continue as tray app". A Windows Defender popup might appear; "Allow access" on BOTH public AND private networks.
 +
 
 +
A new icon will appear in the taskbar. Right-click it and select "Open Status" to bring up a webpage describing the current status. A notification will appear saying something like "Assigning IP address ___ to client ___". You'll want to SSH into the IP address shown.
 +
 
 +
You will be SSHing into any of the IP addresses shown. The [https://mobaxterm.mobatek.net/ MobaXterm SSH client] is recommended. Again, allow access on BOTH public AND private networks. From the start screen, click "Session" in the upper left hand corner, select SSH, fill in the "Remote host" box with the IP, check the box and specify "pi" as the username, and click "OK" to start connecting.
 +
 
 +
=== OS X ===
 +
# Make sure you are NOT connected to any wifi network
 +
# Share wifi. (These three steps are optional and you can skip them if you run into any issues.)
 +
## Go to System Preferences > Sharing
 +
## Under "Internet Sharing", select WiFi in the drop-down menu, and USB in the check box
 +
## Turn on Internet Sharing
 +
# In terminal: <code>arp -a</code>, see if <code>pehuen-pi</code> comes up
 +
# If it does, look at the IP address of the pi and try to SSH into that
 +
# If it doesn't, try SSHing into 192.168.2.2
 +
# If that fails, keep alternating between arp -a and SSH
 +
 
 +
== Remote Desktop ==
 +
Enable a remote desktop connection to the pi for access to a gui:
 +
WINDOWS ONLY, I have tried a few brew solutions to install Remote Desktop for osx, but none are stable
 +
 
 +
---tested on a fresh pi flash, not on bike pi as long as bike pi can install xrdp, functionality should be the same---
 +
 
 +
    - Installing the xrdp package onto the pi, essentially an open source clone of Microsoft’s Remote Desktop functionality
 +
        - sudo apt-get install xrdp
 +
 
 +
---end of things that are subject to change---
 +
 
 +
    - Now it’s installed on the pi, to retrieve hostname to connect to just
 +
        - hostname -I
  
The username (the <code>pi@</code> part) is important because otherwise ssh may try to use your current username, which will almost certainly not be <code>pi</code>).
+
    - Connecting to the pi’s desktop:
 +
        - Use Remote Desktop Connection
 +
        - [https://imgur.com/a/FAJL4yX Picture of Remote Desktop]
 +
        - After inputting ip, a standard login page should appear where you input credentials for the pi
  
Warning! The ssh connection produced by this method is almost unusably slow at times. I (Daniel, April 2019) am trying to fix this.
+
== Footnotes ==
 +
<references />

Latest revision as of 21:24, 18 May 2020

Here's how to connect to the Pi. Note that in all cases, the Pi's username is pi; the password is raspberry; and the answer to "Are you sure you want to continue connecting?" is always "yes".

General notes

The Pi can be configured to create its own ad-hoc wifi network called RPiwireless, or to connect to the LocomotionLab wifi network in Upson 566 (for Internet access).

To configure it, you must first be connected to the Pi. If you can't ssh in at all, you can connect a keyboard and display using the Pi's USB and HDMI ports.

Make sure you have set up the Pi. Otherwise, rPIwireless will not show up. If you do not know how to set up the Pi, read Setting up the Pi.

  • To switch to RPiwireless: sudo cp /etc/network/interfaces-adhoc /etc/network/interfaces
  • To switch to LocomotionLab: sudo cp /etc/network/interfaces-wifi /etc/network/interfaces

Reboot the Pi afterwards to apply any changes.

If you've switched to LocomotionLab, ssh in using ssh pi@10.0.1.50.

Ad hoc (RPiwireless)

OS X

  • Connect to RPiwireless from the WiFi dropdown menu (warning: you (normally) won't be able to access the internet after you do this).
  • At a terminal, run ssh pi@192.168.1.1.
    • The answer to "Are you sure you want to continue connecting?" is "yes"
    • The password is raspberry.
  • If that didn't work, try arp -a at a terminal.
    • If an IP address associated with the hostname pehuen-pi[1] comes up, use that in the SSH command instead.
  • Otherwise, keep trying 192.168.1.1 (192.168.2.2 sometimes works).

Dylan's laptop

Disconnect from all WiFi networks. Open the program Windows Powershell from the Start menu. In the terminal that appears, run netsh wlan connect RPiwireless.

If that worked, the laptop should now be connected to RPiwireless, and complain about no Internet access. This is sensible, since the Pi doesn't have any other way to connect to the Internet.

You may now use an SSH client (either PuTTY or MobaXterm) to connect to pi@192.168.1.1. Not sure which one to use? MobaXterm is easier; open the program using the shortcut on the desktop, then click "New Session", select "SSH", enter 192.168.1.1 as the IP and pi as the username, then connect.

Arch Linux

These instructions will use the tools ip and iw. Make sure you have them installed before proceeding. Also, you might have to do some of these commands with sudo.

Helpful background information: the Arch Wiki's articles on wireless network configuration and ad-hoc networking.

First, make sure your network interface (i.e. network card) doesn't have anything running on it. In the examples below, dev wlp4s0 is used as the name of the interface. If your interface name is different (get the interface name with iw dev, and it'll be after the word "Interface"), replace as necessary. If you use netctl, the following command will stop the current connection:

netctl stop $(netctl list | grep '^\*' | cut -d'*' -f2)

Now, while your interface is down, change it over to IBSS (the type for ad-hoc data):

iw dev wlp4s0 set type ibss

And bring the interface up:

ip link set wlp4s0 up

After that, join the ad-hoc network. Replace FREQUENCY with an actual frequency. Choose the frequency from this table. You'll probably use 2.4 GHz (802.11b/g/n/ax) channels 1 or 2, which are 2412 and 2417 MHz respectively, so you would replace FREQUENCY with 2412 or 2417.

iw dev wlp4s0 ibss join RPiwireless FREQUENCY

Now, register an IP address: (I haven't figured out if this next command is strictly necessary)

ip addr add 192.168.1.2/255.255.255.0 dev wlp4s0

And try to connect: (you may have to wait a minute or so before this starts working)

ssh pi@192.168.1.1

The username (the pi@ part) is important because otherwise ssh may try to use your current username, which will almost certainly not be pi.

Warning! The ssh connection produced by this method is almost unusably slow at times. I (Daniel, April 2019) am trying to fix this. I hypothesize you may be able to switch the channel on the Pi side (by editing the "channel" specified in /etc/network/interfaces) to avoid interference.

Windows 10, newer laptops

First, open Powershell and run netsh wlan show wirelesscapabilities, then look for a line that says "IBSS". It'll either say "Supported" or "Not Supported".

If it says "Not Supported", your current driver doesn't support ad-hoc networks. Microsoft has deprecated ad-hoc IBSS, which is a fancy name for ad-hoc networks of the type discussed on this page. So, you'll need an old driver that supports ad-hoc IBSS, as well as the hardware to run it on. I don't think newer laptops support this. For more information on which hardware supports this, Intel has a list. (Check which network device you have by going to Device Manager, selecting "Devices by type" under the "View" menu, and looking for something that looks like it should be a wireless adapter.) For a potential workaround, see this Super User answer.

If you end up with IBSS being supported, you'll want to open network settings, open the Wi-Fi menu, click "Manage known networks", and then "Add a new network". Enter RPiwireless for the name, keep the security as "Open", and leave both checkboxes unchecked. Now, in Powershell:

netsh wlan set profileparameter RPiwireless connectiontype=ibss

It might give you this error:

Failed to modify the profile. Error 0x8000D: The BSS type is not valid.

In which case your hardware and/or driver doesn't support ad-hoc IBSS.

If it worked, though, you can connect to the Pi's network using:

netsh wlan connect RPiwireless

Now, the Pi doesn't have DHCP, so you'll need to assign it an IP manually. Try DHCPwiz. After that, DHCPwiz will give you an IP address, and then you can use PuTTY or MobaXterm to connect to pi@ the Pi's IP address.

Further reading: this page on connecting to ad-hoc networks using Windows 8.1 or 10

Ethernet

Windows

Connect your computer and the Pi using an Ethernet cable. Make sure "Unidentified network (no internet)" or something similar is showing up in your list of networks. Now, download dhcpwiz (the download is called "DHCP Server" but contains the dhcpwiz executable). Version 2.5.2 works on Windows 10 as of April 2019. Extract the zip file to anywhere, and run the dhcpwiz executable. Now:

  1. On the Welcome screen, click Next.
  2. On Network Interface cards, select "Ethernet". Make sure the IP Address listed for it isn't 0.0.0.0. If "Ethernet" doesn't show up or displays with 0.0.0.0, click "Refresh" periodically until it's fine. Click Next.
  3. On Supported Protocols, check the boxes for HTTP and DNS. Click Next.
  4. On Configuring DHCP for Interface, just click Next.
  5. On Writing the INI file, check the "Overwrite existing file" checkbox, then click the "Write INI file" button. Click Next.
  6. On DHCP configuration completed, check the "Run DHCP server immediatly" checkbox, and click Finish.
  7. On DHCP Server, click "Continue as tray app". A Windows Defender popup might appear; "Allow access" on BOTH public AND private networks.

A new icon will appear in the taskbar. Right-click it and select "Open Status" to bring up a webpage describing the current status. A notification will appear saying something like "Assigning IP address ___ to client ___". You'll want to SSH into the IP address shown.

You will be SSHing into any of the IP addresses shown. The MobaXterm SSH client is recommended. Again, allow access on BOTH public AND private networks. From the start screen, click "Session" in the upper left hand corner, select SSH, fill in the "Remote host" box with the IP, check the box and specify "pi" as the username, and click "OK" to start connecting.

OS X

  1. Make sure you are NOT connected to any wifi network
  2. Share wifi. (These three steps are optional and you can skip them if you run into any issues.)
    1. Go to System Preferences > Sharing
    2. Under "Internet Sharing", select WiFi in the drop-down menu, and USB in the check box
    3. Turn on Internet Sharing
  3. In terminal: arp -a, see if pehuen-pi comes up
  4. If it does, look at the IP address of the pi and try to SSH into that
  5. If it doesn't, try SSHing into 192.168.2.2
  6. If that fails, keep alternating between arp -a and SSH

Remote Desktop

Enable a remote desktop connection to the pi for access to a gui: WINDOWS ONLY, I have tried a few brew solutions to install Remote Desktop for osx, but none are stable

---tested on a fresh pi flash, not on bike pi as long as bike pi can install xrdp, functionality should be the same---

   - Installing the xrdp package onto the pi, essentially an open source clone of Microsoft’s Remote Desktop functionality
        - sudo apt-get install xrdp

---end of things that are subject to change---

   - Now it’s installed on the pi, to retrieve hostname to connect to just 
        - hostname -I
   - Connecting to the pi’s desktop:
        - Use Remote Desktop Connection 
        - Picture of Remote Desktop
        - After inputting ip, a standard login page should appear where you input credentials for the pi

Footnotes

  1. Pehuen Moure was on the team in (at least) 2017