home · contact · privacy
d00efdf7f75fa544e4b718dc8964135bbeebc4d5
[config] / bookworm / setup_scripts / prepare_to_meet_server.sh
1 #!/bin/sh
2 # Do some of the steps necessary to SSH (key-based) with another server.
3 set -e
4
5 expect_n_args 1 "(server IP)" "$@"
6 target="$1"
7
8 # We need a public key to copy over, so generate it if not found.
9 if [ ! -f ~/.ssh/id_rsa.pub ]; then
10     ssh-keygen -N ""
11 fi
12
13 # Add target to ~/.ssh/known_hosts so we don't get
14 # asked for permission at inopportune moments.
15 ssh-keyscan -H "$target" >> ~/.ssh/known_hosts
16
17 # Tell user what to do.
18 echo "APPEND FOLLOWING TO TARGET'S ~/.ssh/authorized_keys:"
19 cat ~/.ssh/id_rsa.pub