Configure Passwordless SSH on Ubuntu 14.04

http://docs.opennebula.org/5.0/deployment/node_installation/kvm_node_installation.html

Step 4. Configure Passwordless SSH

For the life of me I can’t get this to work. When I run this command:

ssh-keyscan … >> /var/lib/one/.ssh/known_hosts

I keep getting this:

bash: syntax error near unexpected token `<’

Why the heck does this have to be so complicated!!!

the documentation literary says:

ssh-keyscan <node1> <node2> <node3> ... >> /var/lib/one/.ssh/known_hosts

The part should be replaced with the real hostnames of your nodes, the stuff is just an example. try “myhostname” instead .

Use something the outpur of like:

cat /etc/hostname

I feel stupid, that makes sense now, but still running into road blocks. They should explain that a little better on their pages. After I try to put my hostname in, while I am logged into oneadmin under terminal, I now get:

bash: /var/lib/one/.ssh/known_hosts: Permission denied

If I try the same command under normal root I get this:

getaddrinfo …: Name or sevice not known

But I can ping the host name I am trying to use?

/var/lib/one/.ssh/known_hosts file should belong to oneadmin. If not, try to chown to oneadmin:oneadmin and then run the ssh-keyscan command while logged in as oneadmin.

here is what I do just run that as root like this ssh-keyscan localhost (replace that with your servers hostname) >> /var/lib/one/.ssh/known_hosts though I recommend running this command as root otherwise you will get the access denied error on oneadmin user unless you use sudo with oneadmin user or just run it as root.
the choice I choose to run it as root is mainly because it is easier(I know that may not be very secure but I like easy more then complicated :slight_smile:)

try this:
sudo su -
(change ownership of /var/lib/one to oneadmin:oneadmin recursively)
chown -Rv oneadmin:oneadmin /var/lib/one
(switch to oneadmin user)
su - oneadmin
ssh-keyscan … >> /var/lib/one/.ssh/known_hosts

(switch to root)
scp /var/lib/one/.ssh/known_hosts :/var/lib/one/.ssh/known_hosts

ssh
chown oneadmin:oneadmin /var/lib/one/.ssh/known_hosts

now it must be set up ok… you can switch to oneadmin user and try ssh etc