Last active
January 13, 2025 13:49
-
-
Save martinhbramwell/4223476 to your computer and use it in GitHub Desktop.
Revisions
-
martinhbramwell revised this gist
Dec 24, 2012 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -98,5 +98,3 @@ wget -O createNewSSHUser.sh https://gist.github.com/raw/4223476/ chmod a+x createNewSSHUser.sh nano createNewSSHUser.sh # -
martinhbramwell revised this gist
Dec 24, 2012 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -97,4 +97,6 @@ rm -f createNewSSHUser.sh wget -O createNewSSHUser.sh https://gist.github.com/raw/4223476/ chmod a+x createNewSSHUser.sh nano createNewSSHUser.sh # ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5y3GQMHriwstpa9l4uvZ99px6OahUB3hEBItLRn/UxZKLYalFoIhEsVDOEqhaoa+rEkXCC2HMmL0TXAxhxMbVRuispq5kDZByixQSclZ0xmHhp+4VcAUY4FfC8/kwz55LzoL3tYb4QEkG71WoqfHOvZ1EzBM91tnndtB+oolBIooV8pm3+InzjPAxw29arXF+JjNgzuzHmIyVrriTezsqG+O0W6ZUiculCFVCWWaY1+7wN+aMNWGW0vEfQD45RtyK9p89JjWYoD4HbfmqQ8RN6VnvXQFn0XCYe9yUgtpWufbbRJpOh/SfqYubviYCtYCDOrVw4IUL19AdsYEs1tYL hasan@hasanPrecise500 -
martinhbramwell revised this gist
Dec 24, 2012 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -51,6 +51,9 @@ function createSSHUser { echo "................................................................" echo "Prepare for SSH tasks" echo "................................................................" # apt-get install -y openssh-server # export A_NEW_USER_SSH_DIR=${A_NEW_USER_HOME}/.ssh mkdir -p ${A_NEW_USER_SSH_DIR} chmod 700 ${A_NEW_USER_SSH_DIR} -
martinhbramwell revised this gist
Dec 23, 2012 . 1 changed file with 0 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,4 @@ #!/bin/bash # # ############################################################################# # Create new SSH user (Ubuntu) -
martinhbramwell revised this gist
Dec 23, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ # Create new SSH user (Ubuntu) # I use this script whenever I need to add a new SSH user to an Ubuntu machine. # Usage: # 1) Download the "raw" with - wget -O createNewSSHUser.sh https://gist.github.com/raw/4223476 # 2) Make it executable with - chmod a+x createNewSSHUser.sh # 3) Uncomment the last line and edit the user & pwd values # 4) Execute it with : sudo ./createNewSSHUser.sh @@ -94,7 +94,7 @@ function createSSHUser { exit 0; ########## Quick start ########### rm -f createNewSSHUser.sh wget -O createNewSSHUser.sh https://gist.github.com/raw/4223476/ chmod a+x createNewSSHUser.sh nano createNewSSHUser.sh -
martinhbramwell revised this gist
Dec 23, 2012 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -89,9 +89,11 @@ function createSSHUser { } # # Example call : # createSSHUser Fred okokokok exit 0; ########## Quick start ########### rm -f createNewSSHUser.sh wget -O createNewSSHUser.sh https://gist.github.com/raw/4223476/67cbb375fa1d854d85899e620fd6c8a25b34cfd4/I%20use%20this%20script%20whenever%20I%20need%20to%20add%20a%20new%20SSH%20user%20to%20an%20Ubuntu%20machine. chmod a+x createNewSSHUser.sh nano createNewSSHUser.sh -
martinhbramwell revised this gist
Dec 23, 2012 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -91,4 +91,8 @@ function createSSHUser { # # Example : # createSSHUser Fred okokokok exit 0; wget -O createNewSSHUser.sh https://gist.github.com/raw/4223476/67cbb375fa1d854d85899e620fd6c8a25b34cfd4/I%20use%20this%20script%20whenever%20I%20need%20to%20add%20a%20new%20SSH%20user%20to%20an%20Ubuntu%20machine. chmod a+x createNewSSHUser.sh nano createNewSSHUser.sh -
martinhbramwell revised this gist
Dec 23, 2012 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,7 @@ #!/bin/bash # touch /root/trashfile.remove rm -f /root/trashfile.remove # # ############################################################################# # Create new SSH user (Ubuntu) -
martinhbramwell revised this gist
Dec 23, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ # Create new SSH user (Ubuntu) # I use this script whenever I need to add a new SSH user to an Ubuntu machine. # Usage: # 1) Download the "raw" with - wget -O createNewSSHUser.sh https://gist.github.com/raw/4223476/67cbb375fa1d854d85899e620fd6c8a25b34cfd4/I%20use%20this%20script%20whenever%20I%20need%20to%20add%20a%20new%20SSH%20user%20to%20an%20Ubuntu%20machine. # 2) Make it executable with - chmod a+x createNewSSHUser.sh # 3) Uncomment the last line and edit the user & pwd values # 4) Execute it with : sudo ./createNewSSHUser.sh -
martinhbramwell revised this gist
Dec 23, 2012 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,6 +14,13 @@ # function createSSHUser { # touch /root/trash 2> /dev/null if [ $? -ne 0 ] then echo "Must execute as root user . . . " echo "sudo ./createNewSSHUser.sh" exit 0; fi export A_NEW_USER=$1 export NEW_USER_PWD=$1 # -
martinhbramwell revised this gist
Dec 9, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -46,6 +46,7 @@ function createSSHUser { echo "................................................................" export A_NEW_USER_SSH_DIR=${A_NEW_USER_HOME}/.ssh mkdir -p ${A_NEW_USER_SSH_DIR} chmod 700 ${A_NEW_USER_SSH_DIR} # pushd ${A_NEW_USER_SSH_DIR} # -
martinhbramwell revised this gist
Dec 7, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ # 1) Download the "raw" with - wget -O createNewSSHUser.sh https://raw.github.com/gist/4223476/f21e1f7037ac0f569a4c596d7d724a7d961f8e13/I%20use%20this%20script%20whenever%20I%20need%20to%20add%20a%20new%20SSH%20user%20to%20an%20Ubuntu%20machine. # 2) Make it executable with - chmod a+x createNewSSHUser.sh # 3) Uncomment the last line and edit the user & pwd values # 4) Execute it with : sudo ./createNewSSHUser.sh # 5) Immediately set a new password by logging in once with - # su newUsrName # ############################################################################# -
martinhbramwell revised this gist
Dec 6, 2012 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,6 +8,8 @@ # 2) Make it executable with - chmod a+x createNewSSHUser.sh # 3) Uncomment the last line and edit the user & pwd values # 4) Execute it with : ./createNewSSHUser.sh # 5) Immediately set a new password by logging in once with - # su newUsrName # ############################################################################# # function createSSHUser { -
martinhbramwell revised this gist
Dec 6, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ # Create new SSH user (Ubuntu) # I use this script whenever I need to add a new SSH user to an Ubuntu machine. # Usage: # 1) Download the "raw" with - wget -O createNewSSHUser.sh https://raw.github.com/gist/4223476/f21e1f7037ac0f569a4c596d7d724a7d961f8e13/I%20use%20this%20script%20whenever%20I%20need%20to%20add%20a%20new%20SSH%20user%20to%20an%20Ubuntu%20machine. # 2) Make it executable with - chmod a+x createNewSSHUser.sh # 3) Uncomment the last line and edit the user & pwd values # 4) Execute it with : ./createNewSSHUser.sh -
martinhbramwell revised this gist
Dec 6, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ # Create new SSH user (Ubuntu) # I use this script whenever I need to add a new SSH user to an Ubuntu machine. # Usage: # 1) Download the "raw" with - wget -O createNewSSHUser.sh # 2) Make it executable with - chmod a+x createNewSSHUser.sh # 3) Uncomment the last line and edit the user & pwd values # 4) Execute it with : ./createNewSSHUser.sh -
martinhbramwell revised this gist
Dec 6, 2012 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,15 @@ #!/bin/bash # # ############################################################################# # Create new SSH user (Ubuntu) # I use this script whenever I need to add a new SSH user to an Ubuntu machine. # Usage: # 1) Download the "raw" it with - wget -O createNewSSHUser.sh # 2) Make it executable with - chmod a+x createNewSSHUser.sh # 3) Uncomment the last line and edit the user & pwd values # 4) Execute it with : ./createNewSSHUser.sh # ############################################################################# # function createSSHUser { # export A_NEW_USER=$1 -
martinhbramwell revised this gist
Dec 6, 2012 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ #!/bin/bash # function createSSHUser { # export A_NEW_USER=$1 @@ -63,7 +65,7 @@ function createSSHUser { echo - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } # # Example : # createSSHUser Fred okokokok -
martinhbramwell created this gist
Dec 6, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,69 @@ function createSSHUser { # export A_NEW_USER=$1 export NEW_USER_PWD=$1 # echo New User is $A_NEW_USER identified by $NEW_USER_PWD # echo "Get ${A_NEW_USER} home directory .. . . . . . . . " export A_NEW_USER_HOME=$( grep "${A_NEW_USER}" /etc/passwd | awk -F: '{print $6}' ) echo "New user's home directory is ${A_NEW_USER_HOME}" # if [ "XX${A_NEW_USER_HOME}" == "XX" ]; then # echo "Create admin group ............................................" addgroup admin # echo "Create a full privileges admin user ..........................." export PASS_HASH=$(perl -e 'print crypt($ARGV[0], "password")' "$NEW_USER_PWD") echo ${PASS_HASH} # addgroup sudo useradd -Ds /bin/bash useradd -m -G admin,sudo -p ${PASS_HASH} ${A_NEW_USER} passwd -e ${A_NEW_USER} # A_NEW_USER_HOME=/home/${A_NEW_USER} else echo "The ${A_NEW_USER} user account is already configured in ${A_NEW_USER_HOME} . . . " fi # echo "................................................................" echo "Prepare for SSH tasks" echo "................................................................" export A_NEW_USER_SSH_DIR=${A_NEW_USER_HOME}/.ssh mkdir -p ${A_NEW_USER_SSH_DIR} # pushd ${A_NEW_USER_SSH_DIR} # # echo "................................................................" echo "Generate SSH key pair for ${A_NEW_USER}" echo "................................................................" rm -f id_rsa* ssh-keygen -f id_rsa -t rsa -N '' -C "${A_NEW_USER}@${A_NEW_USER}.me" # # popd # echo "................................................................" echo "Assign correct ownership ......................................" echo "................................................................" chown -R ${A_NEW_USER}:${A_NEW_USER} /home/${A_NEW_USER} # # echo "................................................................" echo "Here is ${A_NEW_USER}'s public key" echo "................................................................" echo " " cat ${A_NEW_USER_SSH_DIR}/id_rsa.pub echo " " echo " " echo " " echo Done creating new user ${A_NEW_USER} echo - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } # Example : # createSSHUser Fred okokokok