SSH into dual boot computer

0

So as is usual I have a dual boot Kubunutu / Windows 7 box (with cygwin), at certain static IP of local 192.168.0.x range, and I want to SSH to it from my other boxes regardless of which system it's running.

The thing is - I configured Kubuntu and Windows 7 parts separately, so they have different ssh host key (that's inherent in these dual boot setup), but also usernames, and IdentityFile (that is pretty awkward, I just didn't think much of it when I choose Windows 7 account name) and ssh goes crazy because every time I boot to a different OS it thinks someone is MITMing since key for same IP changed.

What's the best I can do here? Deleting ~/.ssh/known_hosts and commenting out different part of ~/.ssh/config every time I log in sort of works, but I'd rather solve it properly-ish.

taw

Posted 2014-02-09T18:19:10.563

Reputation: 1 515

Change the static IP: pick another, close one, have your client ping the first static IP; if it responds ssh into it, if it does not, ping the second IP, and if it responds ssh into it. – MariusMatutiae – 2014-02-09T20:47:35.603

IP is determined by NAT router and it depends on ethernet card's MAC. I could modify MAC in bootup/shutdown scripts, but that sounds like a very wrong thing to do. – taw – 2014-02-09T21:47:38.843

You can easily modify the static IP of your pc in both Windows and Linux, and disable the reserved IP address in the router. – MariusMatutiae – 2014-02-09T22:13:47.667

Answers

2

I'm going to self-answer that.

First I renamed my user account in cygwin's /etc/passwd without changing Windows account name, and moved /home/myoldname to /home/mynewname.

Then I copied ~/.ssh/authorized_keys from Ubuntu to cygwin, so I can use same identity key to access both.

Then I addded following lines in ~/.ssh/config on machine accessing them:

Host 192.168.*.*
  User mynewname
  IdentityFile /path/to/identity.key
  UserKnownHostsile /dev/null
  StrictHostKeyChecking no

This prevents saving key file, leaving me with just mildly annoying message every time I login:

Warning: Permanently added '192.168.x.x.' (RSA) to the list of known hosts.

I can live with that.

taw

Posted 2014-02-09T18:19:10.563

Reputation: 1 515

1

Just if anyone is wondering, you can have two entries with the same ip address in .ssh/known_hosts. SSH will accept the host if one of the entry is valid.

You just have to manually edit .ssh/known_hosts or you can comment one out, ssh with the other and then uncomment.

Example:

  1. You ssh into Kubuntu
  2. You add a dash in the entry corresponding to your ip address
  3. You ssh into Windows
  4. You uncomment the entry for kubuntu in .ssh/known_hosts
  5. You can ssh into both systems without any warning or anything

RomainL

Posted 2014-02-09T18:19:10.563

Reputation: 11