Connecting the dots… Thoughts on Web Development, Infrastructure and Application Scalability
  • Web Development
  • Devops
  • RSS Feed
  • Twitter
  • Facebook

Automatic login on ssh

By
rp
– January 7, 2009Posted in: Web Development

At work/home I end up logging into multiple boxes at the same time, one to manage configuration, other to tail log files and another to check db stuff and the start of the day usually begins by running the same commands over and over again and then typing the password a number of times. Looked up some info to make this less painful by not atleast having to type the password. You can do that by copying your SSH keys to the authorized_keys file of the remote server. So this is how you do it.

Generate your ssh key

busybox$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/luke/.ssh/id_rsa):
/Users/luke/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/luke/.ssh/id_rsa.
Your public key has been saved in /Users/luke/.ssh/id_rsa.pub.
The key fingerprint is:
b5:d6:9f:26:13:15:8r:d5:58:55:bd:8b:e6:d1:a7:61

Now you need to copy this across to the server where you want to be able to login automatically:

busybox$ cat ~/.ssh/id_rsa.pub | ssh luke@enterprise-starship.local  'cat >> .ssh/authorized_keys'
busybox$ password:

Alternatively you can copy them across using the following command:

busybox$ ssh-copy-id -i .ssh/id_rsa.pub luke@enterprise-starship.local

and that’s pretty much it, you now login using your standard ssh command without having to enter your password. You can do the same for other hosts as well, just run the same command for different hosts.

Tags: authentication, automatic login, password, ssh

About rp

Architect for large, highly scalable LAMP applications and Technical Manager with special focus on metrics based continuous improvement of teams and products. Rajat has close to a decade of experience of a very wide range of skills related to infrastructure, middleware, app servers all the way to front-end technologies and software development methodologies including agile, iterative waterfall, waterfall as well as ah-hoc startup using the right approach in the right context to reduce time to market.
  • Twitter Feed
  • Dreamhost Hosting - Unlimited Bandwidth and Diskspace
  • Recent Posts
    • Notes on Git Part I / Quickstart Guide to Git
    • Notes on VirtualBox / Quickstart guide to VirtualBox
    • Notes on MongoDB / Quickstart Guide to MongoDB
    • PuppetConf 2011 – Architecting for the Cloud: AWS Cloud Formation and Puppet – Jinesh Varia
    • Notes on Puppet DSL
  • Recent Comments
    • Making custom AMI and distributing it safely on Setting up local environment to work with Amazon’s EC2 Infrastructure
    • Automation for packaging websites on Packaging up websites for easy deployment
    • rp on Xdebug – Remote Debugging
    • rp on sfDoctrineGuardPlugin: Signup, Validation and Profile
    • rp on sfDoctrineGuardPlugin: Signup, Validation and Profile

About Arras WordPress Theme

Copyright Connecting the dots.... All Rights Reserved.