0

I have two RPis that I'd eventually like to use for different things. I want to be able to use them both headlessly but I don't ever plan on having them plugged into my laptop at the same time when I do this.

I've only ever worked with them headlessly so far and they're connected to my laptop running OS X via an Ethernet cord. When setting up my RPis initially I messed up with the the static IP setting for the Ethernet and could not figure out the IP address of the RPi to login. I ended up editing the cmdline.txt file to include ip=x.x.x.x which finally allowed me to login to my first RPi.

My question: Could I do the same thing with the second Pi - assign it the exact same IP - so I don't have to keep changing the IP address for that connection on my Mac since I'm configuring my DHCP with a manual address?

Again, I'm not planning having them plugged into the laptop at the same time (cannot even if I wanted because of only one Ethernet slot) which I thought might make it okay. But if there are hidden problems I - as a total amateur here - am missing I'd appreciate being told so I don't mess up anything else.

techraf
  • 4,319
  • 10
  • 31
  • 42
chainhomelow
  • 111
  • 2
  • You could, but why not give them two different IP addresses in case you want to plug them in both at once later? (with an Ethernet switch) – user253751 Dec 01 '16 at 05:01

2 Answers2

0

If you are setting IP address that way you are making things hard for yourself, but YES you could do it.

IP addresses are NOT expensive, see how to set it up properly in:- How do I set up networking/WiFi/Static IP

Why do you have to change anything on the Mac? If setup properly you can plug in any IP address in the range. The link above suggests better ways of connecting.

PS I still don't understand WHY people want to assign static addresses - it seems to be some kind of Pi disease.

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • Thank you for the link. I'm not a networker and this is all honestly set up this way for ease of swapping out Pis without having to change anything but your link has given me a lot to think about and likely has an- ultimately - better way. This will be a good lesson in networking for me. I appreciate the resource. – chainhomelow Dec 03 '16 at 00:07
0

If you are using SSH to access these Raspberry Pi's, and both Raspberry Pi's are using different installs of Raspbian, then you will see something like this (this is the output on Mac, unsure about other systems):

ssh pi@169.254.67.153
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:RANDOMKEY.
Please contact your system administrator.
Add correct host key in /Users/michaelbuerger/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/michaelbuerger/.ssh/known_hosts:1
ECDSA host key for 169.254.67.153 has changed and you have requested strict checking.
Host key verification failed.
make: *** [ssh] Error 255

This means every time you would like to SSH to the Pi, you would need to regenerate the key.

--Edit--

I have just learned that you are using OSX so here is some extra information:

To regenerate this key use ssh-keygen -R 169.254.67.153 (change IP, this works in my case)

Now, if you want to avoid regenerating this key, you can just copy the install of Raspbian over to the other Pi's SD card and you will be all set. This is the easy solution in my opinion.
If you want to change it on the current install. Check this out: Changing SSH host keys on Raspbian

techraf
  • 4,319
  • 10
  • 31
  • 42
  • "To regenerate this key use ssh-keygen -R 169.254.67.153" is rubbish! 169.254.67.153 is a Link-local address. – Milliways Dec 01 '16 at 05:16
  • @Milliways That IP is just specific to me, stated here: "(change IP, this works in my case)" – Michael Buerger Dec 01 '16 at 15:28
  • The point is link-local addresses are generated and not guaranteed to be persistent (although most seem to be derived algorithmically) . It makes no sense trying to use for persistent data. – Milliways Dec 01 '16 at 21:53
  • @Milliways Take a look at his question, he has set a static IP. My answer uses my static IP. Even if someone doesn't set a static IP, they should be able to understand it must be changed. What are you on about? – Michael Buerger Dec 02 '16 at 02:55
  • Thanks for the comment about the Raspbian versions. For the time being it looks like using the same version may be the easiest option for me. At this point it's all a matter of convenience as I want to be able to swap them out and run them headlessly with the least amount of fuss, and I can still have the option to change IPs if my needs change later. Thanks! – chainhomelow Dec 03 '16 at 00:03
  • Follow-up question. When setting up both of my RPis originally I went into System Preferences->Network and set 'Configure IPv4" to "Using DHCP with manual address" and then inputted the IP address into the box. What caused my problem was, I inputted a specific IP for my first RPi - allowing me to SSH into it - but when I plugged in the second PI and tried to login using the same IP, I could not login. I changed the IPv4 back to 'DHCP' and tried to assign it a new IP and login but still could not. Using ssh-keygen assigns a new IP but I still can't login - the default password is not accepted. – chainhomelow Dec 04 '16 at 01:10
  • If the default password doesn't work, I don't know a way to login without completely re-installing Raspbian. I believe if you boot up linux on your computer you can access all the files on the card but in my experience getting linux working on a mac machine is a bitch. Btw, if you try to view the card on OSX or Windows only the boot partition files will be viewable normally. – Michael Buerger Dec 05 '16 at 00:39