SSH without password - it's so simple

I am currently dealing with several VMs in Linux :-) and Windows  :-(
In Windows I use the Git-Bash to do most of my command line work.

To easily hop around the different machines via SSH without requiring a password, you can very easily authenticate the machines to access each other.

  1. Generate an ssh key (if not done already):
    ssh-keygen
  2. Add current host's public key to remote host's authorized keys:
    cat .ssh/id_rsa.pub | ssh user@myvm 'cat >> .ssh/authorized_keys'
  3. Done! You can now connect to the machine from the current host:
    ssh user@myvm
No password required anymore. You need to redo this for every new A -> B and B -> A pair of machines you have. Of course, I do not have to tell you that this introduces potential security issues in your infrastructure. Please be careful when dealing with a production environment.

Cheers,
Juve

Comments

噎死麦克 said…
try this

ssh-copy-id user@myvm

instead of

cat .ssh/id_rsa.pub | ssh user@myvm 'cat >> .ssh/authorized_keys'
Uwe Jugel said…
Thanks for the hint! I am now using ssh-copy-id whenever possible. But on some systems (e.g., GitBash in stupid Windows) ssh-copy-id is not available. Then I need my fallback.