Custom Search

Thursday, July 10, 2014

Howto passwordless SSH to Virtual Machine using ssh-keygen

1)
In your Host Machine generate SSH public and private key or use your existing SSH public and private key in the "~./ssh" folder.
#ssh-keygen -t rsa

* This command will create "id_rsa" and "id_rsa.pub" in "~./ssh" folder.

2)
2a)

SSH to your Remote Virtual Machine with username and password.
Example : #saju@192.168.56.192

2b)
* Goto "~./ssh" folder.
* Create a file named "authorized_keys"
* Copy the content in the "id_rsa.pub" fle from your Host Machine to "authorized_keys" file.

Example:
#cd ~./ssh
#touch authorized_keys
#echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzXy5baXmVnfFoBKbLbkhWY8iNJp6ZqFYorQNUwLtHHOXo0mcFjQDQAUpcim+mGxcJkq1b4VmPhtts3jg9p08XMfh3nxNEYsOXAyiwxaN6rmMiPQAubuwloBAE
WdRXmd+166NR6A9tn2U/kKq1pTQi81P8LNkI9O74ZJ6jK6AOg+Qzvl2Dd9rUQ7wnL2GYK923Ckpj68Si3rh7F8hSU2HfyJrFUUsWV0dfszAheXt44Pw51gPSgyJhZd1Ja+omdtzpHGa2SyTV6d/uPd/ISS2mY5sISL1Ywvwk
tNbkC9VmqWP8ZrmN/qd5PgqPVVIhs8TEtj3AWdBhfcW1e5YC1Gn7 saju@ubuntu" > authorized_keys


3)
Goto your Host Machine and SSH to your Virtual Machine without password like
#ssh saju@192.168.56.192
OR
#ssh -i id_rsa saju@192.168.56.192

No comments:

Post a Comment