Dariusz on Software

Methods and Tools

About This Site

Software development stuff

Archive

Easily install public SSH keys on remote Linux server
Tue, 17 May 2011 21:03:21 +0000

Almost every remote server I'm using has password login disabled. Only SSH public key login is allowed. Thus installing new public keys on server to authorize access is very frequent operation. Here's small script that allows to install public key on desired server:

#!/bin/sh

test "$2" || {
    echo "usage: $0 public_key_filename host"
    exit 1
}
KEY="$1"
HOST="$2"
cat $KEY | ssh $HOST "mkdir -p ~/.ssh; cat >> ~/.ssh/authorized_keys"

Small bit of scripting, but makes life much easier.

Tags: linux.

Tags

Created by Chronicle v3.5