It's about generating a config file you ought to put in your ~/.ssh/config , so that there are some sane defaults when you are ssh-ing to your servers.
It's using the amazon cli interface to fetch the instances of your aws infrastructure. Then, concatenating it with a list of custome servers, and that's basically it (I'm using chicken scheme here, with the regex module which you can get via chicken-install):
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; sudo chicken-install shell | |
;; csi -ss ~/bin/generate-ssh-config-file.scm >~/.ssh/config | |
(use shell) | |
(define servers | |
(string-split | |
(capture "aws ec2 describe-instances --output text | grep TAGS | grep Name | cut -f3"))) | |
(define special-servers | |
'(("user1" "host" "hostname"))) | |
(define (print-formatted server) | |
(let ((user (car server)) | |
(host (cadr server)) | |
(hostname (caddr server))) | |
(print "host " host) | |
(print "hostname " hostname) | |
(print "user " user))) | |
(define (main args) | |
(map print-formatted | |
(append | |
(map (lambda (server) | |
(list "rgrau" server server)) | |
servers) | |
special-servers))) |
Also, as I'm super super lazy, I also have a readily available command to prompt me for the server I want to ssh to, and make it ssh there. Quite simple stuff, but hey, it works :)
urxvt -e ssh $(grep 'host ' .ssh/config | awk '{print $2}' | dmenu -l 10)
No hay comentarios:
Publicar un comentario