Quantcast
Channel: linuxadmin: Expanding Linux SysAdmin knowledge
Viewing all articles
Browse latest Browse all 17842

Automating SSH to allow creating a user, and adding the keys so they dont have to log in.

$
0
0

This so i can ssh into a box using the sysadmin account, su to root, and run a script to create a usern, and then set up authorized_keys, so that i dont have to use passwords.

SA.txt contains about 500 host(xxxxx.xxx) and a passwords, obtained from a gpg'd attatchment.

i had hoped to pass this into an array, but apparently bash doesnt do multi dimention arrays, so i wans't sure how to secure this for the moment

this technically seems to work (the loop runs, logs into the first ssh), but it seems to leak passwords into the server, which is bad, and since there are so many, i'm going to miss some if i do it manually

what i have so far:

while read -r Host Pass; #loop seems to run over the top of the commands, instead of running the commands as part of the loop do export SSHPASS=$Pass echo "Attempting to SSH to $Host with Password: $Pass" sshpass -e ssh -t -t sysadmin@$Host #think its because if the -t-t forsing it, but doesnt work without it # want to su here but doesnt work, and spits out passwords done < SA2.txt 

I'm new to this......so excuse my lack of knowledge. Thanks

I already have a script to create the user and have a script to scp them to each host, which works fine...

edit: Apparently we had a kerboros box built in a vm, but it was never implemented, because the boss said no.

submitted by caddywork
[link][22 comments]

Viewing all articles
Browse latest Browse all 17842

Trending Articles