scripts / sshfromanywhere /
Newer Older
25 lines | 0.607kb
mécanisme pour obtenir une c...
Sébastien MARQUE authored on 2018-12-06
1
#!/bin/bash
2

            
3
key="/dev/shm/${0##*/}"
4
pubkey="${key}.pub"
5
onetime_suffix="-OTA"
6
authfile=.ssh/authorized_keys
7
password=""
8

            
9
test -r "${0}.conf" && source "${0}.conf"
10

            
11
test -w "$authfile" || exit
12

            
fix typo
Sébastien MARQUE authored on 2019-12-26
13
sed -i "/ \+${0##*/}$onetime_suffix *$/d" "$authfile"
mécanisme pour obtenir une c...
Sébastien MARQUE authored on 2018-12-06
14

            
15
if test -z "$1"; then
16
    rm -f "$key" "$pubkey"
17
    password+=$(head /dev/urandom | sum | cut -d' ' -f1)
18
    ssh-keygen -qf "$key" -P "$password" -C "${0##*/}$onetime_suffix" || exit
19
    echo "command=\"$0 one-time-key\" $(<$pubkey)" >> "$authfile"
20
    cat "$key" >&2
21
    ${0%%/*}/smsapi "code clé: $password"
22
    rm -f "$key" "$pubkey"
23
else
24
    zsh -i
25
fi