View Single Post
Old 08-19-2013, 03:15 PM   #4
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,907
Karma: 6736094
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
Quote:
Originally Posted by CapitainDerya View Post
I have Ant Script like this:

<exec command="scp -i ${dev.ssh.id} test.azw2 root@kindle:/mnt/us/documents/"/>

But i am using windows os not linux, so it cant run this chunk under windows os.
Ha! That looks familiar

For scp, see knc1's answer. Make sure to modify your %PATH% to include the path where scp resides, or - if you're lazy - just copy scp.exe to \windows or \windows32.

Quote:
I think ant using command shell of default operating system and windows's cmd hasnt got scp support. i dont know what does it means dev.ssh.id on windows.
dev.ssh.id means nothing to windows. It's defined in the ant buildfile, more specifically, here (line 4 of build.xml). Which includes build.properties, where dev.ssh.id is defined on line 33. So you'll need an appropriate build.properties file (or any other means to define that value).

Finally, you will of course need an appropriate key file (man ssh-keygen), and the Kindle has to trust that key in its authorized_keys file. Example on Linux:

Code:
ixtab@mbp:/tmp$ mkdir derya
ixtab@mbp:/tmp$ cd derya/
ixtab@mbp:/tmp/derya$ ls -la
total 68
drwxrwxr-x  2 ixtab ixtab  4096 Aug 19 20:54 .
drwxrwxrwt 42 root  root  61440 Aug 19 20:54 ..
ixtab@mbp:/tmp/derya$ ssh-keygen -C "CaptainDerya's Kindle developer key" -f id_derya
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): (***press ENTER***)
Enter same passphrase again: (***press ENTER again***)
Your identification has been saved in id_derya.
Your public key has been saved in id_derya.pub.
The key fingerprint is:
9a:7a:2e:83:6e:3e:04:99:1d:c5:cd:68:d2:73:0f:28 CaptainDerya's Kindle developer key
The key's randomart image is:
+--[ RSA 2048]----+
|   +.=           |
|  E B =          |
| + = o o         |
|+ .     .        |
| .      S        |
|  .    o         |
| . .  o          |
|  + o..          |
| +o..=.          |
+-----------------+
ixtab@mbp:/tmp/derya$ ls -la
total 76
drwxrwxr-x  2 ixtab ixtab  4096 Aug 19 20:56 .
drwxrwxrwt 42 root  root  61440 Aug 19 20:54 ..
-rw-------  1 ixtab ixtab  1675 Aug 19 20:56 id_derya
-rw-r--r--  1 ixtab ixtab   417 Aug 19 20:56 id_derya.pub
ixtab@mbp:/tmp/derya$ cat id_derya.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDu/xUUW9vhF6spgd5nI8WmRxuXj/pM+fVgG+tK/CKrksbvhhX8QY4yLHvIpX5ufWYT6l5g8B+dYuCYzfCZC03Ry0AsS8fPBFMOdZcwaElBGAQ/K/GvKXUWJSNLcbiuYIXzNg1U7VMNvQNM/GHS9VsXztBwicqVOiQJpmQLq9PxWGm5hzZCqv6USQ9ZqNSSL9mkW5hkmHN7XJBt01Yvl4Jt7yxuERpRYeFJaE81xOxqKRYl3c2h0tqbqIbN73kBJmXAy0qj4+ZWKpRCnm4cSvsN2M6HsgRHrxiuYsCp1+GF8yJIwD++Bb6WOXmq+DbXxQ9Vcc3PQdxSG/N5oO4yVIz/ CaptainDerya's Kindle developer key

ixtab@mbp:/tmp/derya$ scp id_derya.pub root@kindle:/mnt/us/usbnet/etc/authorized_keys
Warning: Permanently added 'kindle,192.168.15.244' (RSA) to the list of known hosts.


Welcome to Kindle!

root@kindle's password: (***(any) password required, just press ENTER***) 
id_derya.pub                                                                                                                                                                                              100%  417     0.4KB/s   00:00    
ixtab@mbp:/tmp/derya$ ssh -i id_derya root@kindle 'echo "logged in without password"; whoami'
Warning: Permanently added 'kindle,192.168.15.244' (RSA) to the list of known hosts.


Welcome to Kindle!

logged in without password
root
Note: the last login attempt did not require a password, because it used public-key authentication using the (private) key id_derya. That worked because the corresponding public key id_derya.pub was added to the Kindle's authorized_keys before(*). This means that calling ssh -i <that-private-key> or scp -i <that-private-key> will do whatever it is supposed to do without asking for a password from now on. Which is what you want in an automated build file.

PS: (*) Well actually, the authorized_keys files has been overwritten to contain only that public key. But that's a detail.
PPS: If anybody feels like this is useful enough as a short HOWTO to end up on the Wiki or index, feel free to link to it -- no, I'm not too lazy, I'm not sure if and where it fits.


EDITED TO ADD:
I also have this line in my /etc/hosts:
192.168.15.244 kindle

which is why "root@kindle" works. Otherwise, use "root@192.168.15.244".

And finally, a minor note: My .ssh/config looks like this:
Code:
Host 192.168.15.244
	StrictHostKeyChecking no
	UserKnownHostsFile /dev/null

Host kindle
	StrictHostKeyChecking no
	UserKnownHostsFile /dev/null
This is to prevent SSH from bitching if I plug a different Kindle device with a different host key. It will silently accept any host key for host "192.168.15.244" or "kindle". The only minor annoyance is the constant "Warning: Permanently added 'kindle,192.168.15.244' (RSA) to the list of known hosts." thing.

Last edited by ixtab; 08-19-2013 at 03:32 PM.
ixtab is offline   Reply With Quote