Created
August 1, 2020 20:20
-
-
Save snapo/a73dbe996311818d71cc81d1e025d908 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
username="xxxx" | |
password="xxxx" | |
# Update and get required packages | |
apt-get update && apt-get -y upgrade | |
apt-get -y purge | |
apt-get install -y lftp sshfs | |
# Remove existing private keys | |
rm -rf ~/.ssh/id_rs* | |
> ~/.ssh/known_hosts | |
# Create new Key | |
ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa <<<y 2>&1 >/dev/null | |
ssh-keygen -e -f .ssh/id_rsa.pub | grep -v "Comment:" > .ssh/id_rsa_rfc.pub | |
cat .ssh/id_rsa_rfc.pub >> a_keys | |
# Copy key to Hetzners location | |
lftp ftp://$username:$password@$username.your-storagebox.de -e "mkdir .ssh;chmod 700 .ssh;cd .ssh;put a_keys;rm authorized_keys;mv a_keys authorized_keys;chmod 600 authorized_keys; bye" | |
# Test Mount Directory default 1 connection | |
mkdir -p /mnt/sftpdisk | |
sshfs -o allow_root,IdentityFile=/root/.ssh/id_rsa,StrictHostKeyChecking=no $username@$username.your-storagebox.de:/ /mnt/sftpdisk | |
# Print available Disks | |
df -hT | |
# Unmount again | |
#######fusermount -u /mnt/sftpdisk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment