From c83b3a03a83d5b1863dcb0bdd341fe68eea1f30a Mon Sep 17 00:00:00 2001 From: Artem Sapegin Date: Wed, 12 Dec 2012 15:18:16 +0400 Subject: [PATCH] Bash: ssh-key function. --- docs/Bash.md | 4 ++++ includes/bash_functions.bash | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/docs/Bash.md b/docs/Bash.md index 744db47..0cbcc50 100644 --- a/docs/Bash.md +++ b/docs/Bash.md @@ -88,6 +88,10 @@ Get gzipped file size. Test if HTTP compression (RFC 2616 + SDCH) is enabled for a given URL. Send a fake UA string for sites that sniff it instead of using the Accept-Encoding header. +### ssh-key + +Copy public SSH key to clipboard. Generate it if necessary. + ### add-ssh-host Create an SSH key and uploads it to the given host. diff --git a/includes/bash_functions.bash b/includes/bash_functions.bash index 8a7d437..f1800cd 100644 --- a/includes/bash_functions.bash +++ b/includes/bash_functions.bash @@ -80,6 +80,17 @@ function nyan() { echo } +# Copy public SSH key to clipboard. Generate it if necessary +ssh-key() { + file="$HOME/.ssh/id_rsa.pub" + if [ ! -f "$file" ]; then + ssh-keygen -t rsa + fi + + cat "$file" | c + echo "Your public key copied to clipboard." +} + # Create an SSH key and uploads it to the given host # Based on https://gist.github.com/1761938 add-ssh-host() {