User Tools

Site Tools


sysadmin:ssh_conf

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sysadmin:ssh_conf [2025/11/21 16:24] mlivolsisysadmin:ssh_conf [2025/11/21 16:31] (current) mlivolsi
Line 8: Line 8:
  
 <code> <code>
 +
 #!/bin/bash #!/bin/bash
  
-typeset -i looper=0 +looper=0 
-typeset -A hostArray+hosts=()
  
-while read comment hostName +# Read only the lines we care about 
-do +grep -E 'Host|#_' ~/.ssh/config | \ 
-    is_break=`echo $comment | cut -c 1-2` +grep -Ev 'HostName|StrictHostKeyChecking|UserKnownHostsFile|HostKeyAlgorithms'
-    if [ ${is_break} == "#_" ]; then +while read -r comment hostName _; do 
-       echo "-----------------------------------------------------------"+ 
 +    if [[ "${comment}== "#_"* ]]; then 
 +        echo "-----------------------------------------------------------"
     else     else
-       looper=$looper+1 +        ((looper++)) 
-       hostArray[$looper]=$hostName +        hosts[$looper]="$hostName" 
-       echo "${looper}) $hostName"+        echo "${looper}) $hostName"
     fi     fi
-done <<< $(cat ~mlivolsi/.ssh/config | egrep 'Host|#_' | grep -v 'HostName' | grep -v 'StrictHostKeyChecking' | grep -v 'UserKnownHostsFile' | grep -v 'HostKeyAlgorithms' ) 
  
-echo -"===> \c+done 
-read answer + 
-ssh  "${hostArray[$answer]}"+echo -"===>
 +read -r answer 
 + 
 +ssh "${hosts[$answer]}" 
 +</code> 
 + 
 +My ssh config 
 <code> <code>
 +#---------------------------------------------------------------
 +#_ Mike Network
 +#---------------------------------------------------------------
 +Host n150-host
 +    HostName x.x.x.x
 +    User <your username>
 +    ForwardAgent yes                   # forward agent to target
 +    X11Forwarding yes                  # I need this for kvm gui
 +    ForwardX11Trusted yes
 +</code>
 +
 +Obviously, you need to setup open-ssh on your servers and copy the required keys
sysadmin/ssh_conf.1763742241.txt.gz · Last modified: by mlivolsi