#!/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
» Scripting mplayer playlists ... in shell osx mac bash script unix linux mplayer web video internet youtube playlist playmovs mixmovs newpldir openpl playone
» Scripting mplayer playlists ... in shell osx mac bash script unix linux mplayer web video internet youtube playlist playmovs mixmovs newpldir openpl playone
» Scripting mplayer playlists ... in shell osx mac bash script unix linux mplayer web video internet youtube playlist playmovs mixmovs newpldir openpl playone
» Scripting mplayer playlists ... in shell osx mac bash script unix linux mplayer web video internet youtube playlist playmovs mixmovs newpldir openpl playone
» Customize system-wide $PATH ... in ssh shell osx mac bash bashrc unix linux file login sshd startup profile git path interactive
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
;-)