Strony

wtorek, 16 października 2012

SSH Keys - ssh: Exited: String too long


W celu wygenerowania pary kluczy do autoryzacji w usłudze ssh zainstalowałem OpenSSH keygen:
openssh-keygen - 5.8p2-2 - OpenSSH keygen.

Po wygenerowaniu pary kluczy przekopiowałem klucz publiczny na zdalny serwer
Niestety próba połączenia zwróciła błąd:
ssh -i /root/.ssh/id_rsa  root@remotehost
ssh: Exited: String too long

Rozwiązanie:
Klucze trzeba wygenerowac za pomocą dostępnego w OpenWRT dropbearkey

localhost
dropbearkey -t rsa -f /root/.ssh/id_rsa
dropbearkey -y -f /root/.ssh/id_rsa | grep ssh-rsa > /root/.ssh/id_rsa.pub
scp /root/.ssh/id_rsa.pub root@remotehost:/root

Remotehost
cat /root/id_rsa.pub >> /etc/dropbear/authorized_keys
chmod 600 /etc/dropbear/authorized_keys

localhost
ssh -i /root/.ssh/id_rsa root@remotehost

BusyBox v1.15.3 (2011-11-11 18:03:51 CET) built-in shell (ash)
Enter 'help' for a list of built-in commands.

2011-11-12 - r28934
  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 Backfire (10.03.x, latest version. Always.) -------
  * 1/3 shot Kahlua    In a shot glass, layer Kahlua
  * 1/3 shot Bailey's  on the bottom, then Bailey's,
  * 1/3 shot Vodka     then Vodka.
 ----------( by obsy, http://eko.one.pl/ )----------
Booted from internal flash
root@remotehost:~$


Do czego można to wykorzystać?
Np. Backup
tar czf - /overlay | ssh -i /root/.ssh/id_rsa root@backupserver "cat > /mnt/backupdir/backup-host1-$(date +%Y-%m-%d-%s).tgz"