Create ~/.ssh and ~/.ssh/config if does not exits
parent
867b0fd11c
commit
72224ab034
|
|
@ -7,14 +7,15 @@ function add_ssh() {
|
||||||
param '2: hostname'
|
param '2: hostname'
|
||||||
param '3: user'
|
param '3: user'
|
||||||
group 'ssh'
|
group 'ssh'
|
||||||
|
[[ $# -ne 3 ]] && echo "add_ssh host hostname user" && return 1
|
||||||
|
[[ ! -d ~/.ssh ]] && mkdir -m 700 ~/.ssh
|
||||||
|
[[ ! -e ~/.ssh/config ]] && touch ~/.ssh/config && chmod 600 ~/.ssh/config
|
||||||
echo -en "\n\nHost $1\n HostName $2\n User $3\n ServerAliveInterval 30\n ServerAliveCountMax 120" >> ~/.ssh/config
|
echo -en "\n\nHost $1\n HostName $2\n User $3\n ServerAliveInterval 30\n ServerAliveCountMax 120" >> ~/.ssh/config
|
||||||
}
|
}
|
||||||
|
|
||||||
function sshlist() {
|
function sshlist() {
|
||||||
about 'list hosts defined in ssh config'
|
about 'list hosts defined in ssh config'
|
||||||
group 'ssh'
|
group 'ssh'
|
||||||
|
|
||||||
awk '$1 ~ /Host$/ {for (i=2; i<=NF; i++) print $i}' ~/.ssh/config
|
awk '$1 ~ /Host$/ {for (i=2; i<=NF; i++) print $i}' ~/.ssh/config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue