Skip to content

I Have A PC

Tech Tips and How-To's Since 2010
Menu
  • Home
    • Tech
    • Apps
    • Misc
    • Linux
    • Windows
  • Giveaways and Freebies
  • Free Stuff
  • Sitemap
  • Copyright Policy
  • Cookie Policy
  • Contact
  • About
HomeLinuxHow To Configure SSH Auto Login Using Keys In Linux

How To Configure SSH Auto Login Using Keys In Linux

September 28, 2018

It is convenient to setup a key based authentication when trying to remotely connect using SSH. This is also useful when running scripts that require a non-interactive login without any password.

Setting this up is not just for servers, you can also use your Linux PC to setup a key pair with a remote system which you can then use to backup data and so on.

Basically, this requires two steps :

1.Generating a key pair

2.Copying the public key to remote system 

Here is how :

Generating a key pair :

From the source system, generate a key pair using the following command at Terminal :

[cc lang=”bash”]

ssh-keygen

[/cc]

Hit Enter at the prompts that follow.

generating key pair in Linux for remote login

The key pair is now generated and will be stored in the home directory in .ssh folder. (~/.ssh). [~ is short for accessing home directory, more about  Linux commands here. ]

The default key pair will be id_rsa which is private and belongs to the local system, and id_rsa.pub which is the public key. The public key needs to be copied to the destination system.

Copying the public key :

Enter the following command to copy it to remote system :

[cc lang=”bash”]

ssh-copy-id -i ~/.ssh/id_rsa.pub username@remotemachineaddress

[/cc]

copying public key to remote system where auto login is needed

Once the public key is copied and added, try to login to remote system. There will now be no need to enter password manually.

ssh login without password using key pair

Also, note that the copied public key will be available in ~/.ssh as authorized_keys on remote system.

public key on remote system

This can be useful to know when troubleshooting authentication errors.

All done.

 

Tags:generating key pairs in Linux, how to setup key based authentication for ssh, key based authentication for ssh, linux command line tips, ssh auto login using keys

Related Posts

Firefox logo

How To Manually Set Cache Size In Firefox 5

How To Customize Unity Desktop In Ubuntu 12.04 LTS ‘Precise Pangolin’

How To Customize Unity Desktop In Ubuntu 12.04 LTS ‘Precise Pangolin’

LXDE: A Lightweight Desktop For Linux Mint / Ubuntu

About The Author

admin

  • Bluesky
  • Email
  • Facebook
  • Twitter
  • YouTube

Free E-books

Linux Command-Line Cheatsheet
Linux Command-Line Basics
Linux Shell Scripting Primer

Free GWS Trial

Try Google Workspace free for 14 days

Archives

  • Bluesky
  • Email
  • Facebook
  • Twitter
© 2026 I Have A PC | WordPress Theme by Superb WordPress Themes
Back to Top ↑