#!/bin/bash ## USAGE: add_to_server.sh remote_server ## This script will add your ssh dsa public key to remote_server's authorized_keys list, ## assuming that everything is in it's default location set -v # verbose output username="USERNAME" # CHANGE ME!!!! remote_server=$1 # assigns the first commandline argument to $remote_server ## Pipe the public key to ssh, then remotely touch the file to make sure it will be there, and concat to the end of it. ## Might work without the touch? cat ~/.ssh/id_dsa.pub | ssh ${username}@${remote_server} "touch ~/.ssh/authorized_keys && cat - >> ~/.ssh/authorized_keys" exit 0
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Bash script to export ssh public key to a remote server (See related posts)
Comments on this post
I mean.
You need to create an account or log in to post comments to this site.
Related Posts
» SSH dynamic forward (Linux) in ssh tunneling shell proxy bash linux dynamic tunnel sshd forward forwarding vpn openssh
» Bash function to copy SSH DS... in ssh shell zsh bash
» Bash script to perform initi... in rails shell svn bash script
» linux ubuntu ssh login in ssh linux administration
» Cache a local copy of Google... in shell google bash script urchin sh googleanalytics analytics
» Human Readable ls and df com... in osx bash unix linux commandline terminal
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails
ssh-copy-id ~/.ssh/id_dsa.pub USERNAME@exammple.com
;-)