From: Nicolas Boisselier Date: Wed, 7 Sep 2016 10:17:23 +0000 (+0200) Subject: openssh.sh X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=17c28d0fa136001af6323cefb966cd05a2bf71f8;p=nb.git openssh.sh --- diff --git a/etc/profile.d/functions b/etc/profile.d/functions index d11f3e03..dfd70316 100644 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -579,6 +579,27 @@ is_prompt() { url2nc() { local in="cat"; - [ -n "$@" ] && in="echo $@"; - $in | perl -MURI::Split -ne 'BEGIN{%port=("ssh"=>22,"https"=>443,"http"=>80);}; chomp($_); m,^\w+://, or $_="ssh://$_"; s,:([a-zAZ]),/$1,; @_=URI::Split::uri_split($_) or next; $_=$_[1]; s/^[^@]+@//; s/:/ / or $_.=" ".$port{$_[0]||"ssh"}; print "$_\n"' + [ -n "$*" ] && in="echo $*"; + local IFS=$'\n' + eval $in | perl -MURI::Split -ne 'BEGIN{%port=("ssh"=>22,"https"=>443,"http"=>80);}; + chomp($_); + + if (/^([\.\w-_]+)\s+(\d+)$/) { + @_ = ($2,$1); + } else { + s,:([a-zAZ]),/$1,; + m,^\w+://, or $_="ssh://$_"; + @_ = URI::Split::uri_split($_) or next; + } + + $_=$_[1]; + s/^[^@]+@//; + + if ($_[0] =~ /^\d+$/) { + $_ .= " $_[0]"; + } else { + s/:/ / or $_.=" ".$port{$_[0]||"ssh"}; + } + print "$_\n" + ' } diff --git a/etc/profile.d/mac.sh b/etc/profile.d/mac.sh index 7231056c..cd0db620 100644 --- a/etc/profile.d/mac.sh +++ b/etc/profile.d/mac.sh @@ -51,3 +51,9 @@ mac_install_dmg() { sudo installer --verbose -pkg "${MOUNTDIR}/"*.pkg -target / sudo hdiutil detach "${MOUNTDIR}" } + +mac_keychain_add() { + local in="cat"; + [ -n "$*" ] && in="echo $*"; + eval $in | sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain +} diff --git a/etc/profile.d/openssl.sh b/etc/profile.d/openssl.sh new file mode 100644 index 00000000..44e5fbce --- /dev/null +++ b/etc/profile.d/openssl.sh @@ -0,0 +1,3 @@ +openssl_site2pem() { + openssl s_client -connect $(url2nc $@|sed 's/ /:/') -showcerts /dev/null | openssl x509 -outform PEM +}