Last active
August 29, 2015 13:56
-
-
Save Xennis/9325385 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 | |
BASEDIR=`dirname $0` | |
# --------------------------- Settings ---------------------------- | |
USER=root | |
HOST= | |
# --------------------------- Include gernal scripts ------------------------ | |
#source general_functions.sh | |
# --------------------------- Functions ---------------------------- | |
function copy_ssh_key() { | |
#ssh-copy-id ${user}@${host} | |
cat ~/.ssh/id_rsa.pub | ssh ${USER}@${HOST} "cat >> ~/.ssh/authorized_keys" | |
} | |
function copy_ssh_key_files() { | |
scp ~/.ssh/id_rsa ~/.ssh/id_rsa.pub ${USER}@${HOST}:~/.ssh/ | |
} | |
function copy_setup_file() { | |
scp setup_server.sh general_functions.sh ${USER}@${HOST}:~/ | |
} | |
function ssh_to_server() { | |
ssh ${USER}@${HOST} | |
} | |
# Deletes host from known_hosts file | |
function clear_known_hosts() { | |
sed -i /${HOST}/d ~/.ssh/known_hosts | |
} | |
# --------------------------- Menu ---------------------------- | |
echo " " | |
PS3='Please enter your choice: ' | |
options=("clear_known_host" "copy_ssh_key" "copy_ssh_key_files" "copy_setup_file" "ssh_to_server" "exit") | |
select opt in "${options[@]}" | |
do | |
case $opt in | |
"copy_ssh_key") | |
echo ">>> ${opt}" | |
copy_ssh_key | |
;; | |
"copy_ssh_key_files") | |
echo ">>> ${opt}" | |
copy_ssh_key_files | |
;; | |
"copy_setup_file") | |
echo ">>> ${opt}" | |
copy_setup_file | |
;; | |
"ssh_to_server") | |
echo ">>> ${opt}" | |
ssh_to_server | |
;; | |
"clear_known_host") | |
echo ">>> ${opt}" | |
clear_known_hosts | |
;; | |
"exit") | |
break | |
;; | |
*) echo invalid option;; | |
esac | |
done |
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 | |
BASEDIR=`dirname $0` | |
function install_essentials() { | |
apt-get update | |
apt-get install git-core | |
} | |
# http://askubuntu.com/questions/205378/unsupported-locale-setting-fault-by-command-not-found | |
function configure_locals() { | |
export LANGUAGE=en_US.UTF-8 | |
export LANG=en_US.UTF-8 | |
export LC_ALL=en_US.UTF-8 | |
locale-gen en_US.UTF-8 | |
dpkg-reconfigure locales | |
} | |
function create_user() { | |
if [ "$#" -lt 1 ] | |
then | |
echo "Usage create_user <user-name>" | |
echo "Example: create_user myUser" | |
echo "" | |
exit 1 | |
else | |
local username="$1" | |
fi | |
# create user with home directory (-m) | |
useradd -m ${username} | |
# admin rights | |
adduser ${username} sudo | |
# create password | |
passwd ${username} | |
# switch to user | |
su -c ${username} | |
mkdir ~/.ssh | |
chmod 700 ~/.ssh | |
} | |
#install_essentials | |
#configure_locals | |
#create_user neo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment