-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild-ssh.sh
More file actions
33 lines (28 loc) · 777 Bytes
/
build-ssh.sh
File metadata and controls
33 lines (28 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
if [ $# -eq 1 ]; then
rcfile=$1
if [ ! -f $rcfile ]; then
echo "rcfile not found!"
exit
fi
else
echo "Pass rcfile as first argument, e.g. bash build-4-ssh.sh ~/.bashrc"
exit
fi
# set up ssh client
ssh-keygen
sudo apt -y install keychain
tee -a $rcfile <<< \
'keychainfile=~/.keychain/$(hostname)-sh
alias add-key="keychain ~/.ssh/id_rsa && source $keychainfile"
if [ -f $keychainfile ]; then
source ~/.keychain/$(hostname)-sh
fi'
# set up ssh server
sudo apt -y install openssh-server
sudo systemctl restart ssh
# disable root login
sudo sed -i -e 's/#PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config
sudo systemctl restart ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
sudo reboot now