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
ff5e0279
Commit
ff5e0279
authored
Aug 07, 2015
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add_eterkey.sh: set VEID always
parent
0d84b0f9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
+13
-4
add_eterkey.sh
rooter/add_eterkey.sh
+13
-4
No files found.
rooter/add_eterkey.sh
View file @
ff5e0279
...
...
@@ -12,7 +12,7 @@ docmd()
fatal
()
{
echo
"Error:
$@
"
echo
-e
"Error:
$@
"
exit
1
}
...
...
@@ -20,8 +20,17 @@ USERNAME=$1
HOST
=
$2
VEID
=
$3
[
-n
"
$USERNAME
"
]
||
fatal
"Usage:
$0
username host [VEID | -l]"
[
-n
"
$HOST
"
]
||
fatal
"Usage:
$0
username host [VEID | -l]"
Help
=
"Usage:
$0
USERNAME HOST {VEID | -l}
\n
HOST - from yours ssh alias
\n
VEID - container ID or 0 for host system"
if
[
"
$USERNAME
"
=
"-h"
]
;
then
echo
-e
"
$Help
"
exit
fi
if
[
-z
"
$USERNAME
"
]
||
[
-z
"
$HOST
"
]
||
[
-z
"
$VEID
"
]
;
then
fatal
"
$Help
"
fi
USERKEY
=
$(
ssh rooter@server get pubkey
$USERNAME
)
...
...
@@ -38,7 +47,7 @@ HSSH=/home/$USERNAME/.ssh
ADDKEYCMD
=
"
$SUDO
useradd
$USERNAME
;
$SUDO
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
if
[
-z
"
$VEID
"
]
||
[
"
$VEID
"
=
0
]
;
then
echo
"Copy key for
$USERNAME
to
$HOST
"
echo
"
$USERKEY
"
| docmd ssh
$HOST
"
$ADDKEYCMD
"
ssh
$HOST
$SUDO
ls
/home/
$USERNAME
/.ssh
-l
...
...
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