Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-admin-essentials
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etersoft-admin-essentials
Commits
3230488b
You need to sign in or sign up before continuing.
Commit
3230488b
authored
Oct 15, 2013
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve add_eterkey
parent
347091c3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
add_eterkey.sh
etersoft/add_eterkey.sh
+15
-1
No files found.
etersoft/add_eterkey.sh
100644 → 100755
View file @
3230488b
...
...
@@ -23,17 +23,31 @@ VEID=$3
[
-n
"
$USERNAME
"
]
||
fatal
"Usage:
$0
username host [VEID | -l]"
USERKEY
=
/home/
$USERNAME
/.ssh/id_dsa.pub
if
[
"
$USERNAME
"
=
"root"
]
;
then
USERKEY
=
/root/.ssh/id_dsa.pub
fi
[
-r
"
$USERKEY
"
]
||
USERKEY
=
/home/
$USERNAME
/.ssh/id_rsa.pub
[
-r
"
$USERKEY
"
]
||
fatal
"Can't read ssh key
$USERKEY
"
ssh
$HOST
echo
||
fatal
"Host
$HOST
is not sshed"
ADDKEYCMD
=
"useradd
$USERNAME
; su -
$USERNAME
-c 'mkdir -p ~/.ssh ; chmod 700 ~/.ssh ; touch ~/.ssh/authorized_keys ; chmod 600 ~/.ssh/authorized_keys' ; cat >>/home/
$USERNAME
/.ssh/authorized_keys"
# FIXME: почему-то в cat не раскрывается тильда!
#ADDKEYCMD="useradd $USERNAME ; su - $USERNAME -c 'mkdir -p ~/.ssh ; chmod 700 ~/.ssh ; touch ~/.ssh/authorized_keys ; chmod 600 ~/.ssh/authorized_keys' ; cat >> /home/$USERNAME/.ssh/authorized_keys"
HSSH
=
/home/
$USERNAME
/.ssh
ADDKEYCMD
=
"useradd
$USERNAME
; su -
$USERNAME
-c 'mkdir -p
$HSSH
; chmod 700
$HSSH
; touch
$HSSH
/authorized_keys ; chmod 600
$HSSH
/authorized_keys' ; cat >>
$HSSH
/authorized_keys"
# copy key in host system
if
[
-z
"
$VEID
"
]
;
then
echo
"Copy key for
$USERNAME
to
$HOST
"
cat
$USERKEY
| docmd ssh
$HOST
"
$ADDKEYCMD
"
ssh
$HOST
ls
/home/
$USERNAME
/.ssh
-l
#ssh -i $USERKEY $USERNAME@$HOST ls ~/.ssh -l
# TODO (.gitconfig)
# git config --global user.email "you@example.com"
# git config --global user.name "Your Name"
exit
fi
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment