Bash Command to Add an SSH Key to a Remote Host

15th June 2012 in Coding Tags: linux, system-administration

Today I want to share with you an useful bash command to quickly add an SSH key to a remote host.

Assuming you already generated an SSH key for your local machine and public RSA key access is active on your remote machine, the command is:

$ cat /home/<local_user>/.ssh/id_rsa.pub | ssh <remote_user>@<host> 'cat >> .ssh/authorized_keys'

Substitute <local_user> with the username on your local machine (eg: nemesis), <remote_user> with the user for which you want to log in on your remote server (eg: root) and <host> with the host (eg: nemesisdesign.net).

Nice isn't it? Thanks to Andrea Ferraresi for this tip.

Retweet

Comments

Leave your comment

Categories

Let's be social

Popular posts

Latest Comments

  1. I got very good results with this, thanks for sharing.

    By Yasir Atabani in How to speed up tests with Django and PostgreSQL

  2. Hi Amad, for any question regarding OpenWISP, use one of the support channels: http://openwisp.org/support.html

    By Federico Capoano in How to install OpenWISP

  3. Sir please guid , i have install the ansible-openwisp2 , now how to add the access points . What is the next procedure . Please help.

    By Ahmad in How to install OpenWISP

  4. Hi Ronak, for any question regarding OpenWISP, use one of the support channels: http://openwisp.org/support.html

    By Federico Capoano in netjsonconfig: convert NetJSON to OpenWRT UCI

  5. Hi, I have installed openwisp controller using ansible playbook. Now, i am adding the configurations automatically using OPENWRT devices in openwisp file by specifying shared_key so can you suggest me if I want to set limit to add configuration how can i do it?

    By Ronak in netjsonconfig: convert NetJSON to OpenWRT UCI

Popular Tags

battlemesh censorship creativity criptography django event fosdem google-summer-of-code ibiza inspiration javascript jquery linux nemesisdesign netjson ninux nodeshot open-source openwisp openwrt performance photo programming python security staticgenerator talk upload wifi wireless-community