Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
337e1471
Commit
337e1471
authored
Aug 31, 2012
by
Stéphane Graber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sshd: run dhclient; allow adding a root ssh key
Signed-off-by:
Serge Hallyn
<
serge.hallyn@ubuntu.com
>
Acked-by:
Stéphane Graber
<
stgraber@ubuntu.com
>
parent
9ac3ffb5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
6 deletions
+38
-6
lxc-sshd.in
templates/lxc-sshd.in
+38
-6
No files found.
templates/lxc-sshd.in
View file @
337e1471
...
...
@@ -88,6 +88,17 @@ HostbasedAuthentication no
PermitEmptyPasswords yes
ChallengeResponseAuthentication no
EOF
if
[
-n
"
$auth_key
"
-a
-f
"
$auth_key
"
]
;
then
u_path
=
"/root/.ssh"
root_u_path
=
"
$rootfs
/
$u_path
"
mkdir
-p
$root_u_path
cp
$auth_key
"
$root_u_path
/authorized_keys"
chown
-R
0:0
"
$rootfs
/
$u_path
"
chmod
700
"
$rootfs
/
$u_path
"
echo
"Inserted SSH public key from
$auth_key
into /home/ubuntu/.ssh/authorized_keys"
fi
return
0
}
...
...
@@ -112,13 +123,17 @@ lxc.mount.entry=/usr usr none ro,bind 0 0
lxc.mount.entry=/sbin sbin none ro,bind 0 0
lxc.mount.entry=tmpfs var/run/sshd tmpfs mode=0644 0 0
lxc.mount.entry=@LXCTEMPLATEDIR@/lxc-sshd sbin/init none bind 0 0
lxc.mount.entry=proc
$rootfs
/proc proc nodev,noexec,nosuid 0 0
EOF
if
[
"
$(
uname
-m
)
"
=
"x86_64"
]
;
then
cat
<<
EOF
>>
$path
/config
# if no .ipv4 section in config, then have the container run dhcp
grep
-q
"^lxc.network.ipv4"
$path
/config
||
touch
$rootfs
/run-dhcp
if
[
"
$(
uname
-m
)
"
=
"x86_64"
]
;
then
cat
<<
EOF
>>
$path
/config
lxc.mount.entry=/lib64 lib64 none ro,bind 0 0
EOF
fi
fi
}
usage
()
...
...
@@ -129,10 +144,10 @@ EOF
return
0
}
options
=
$(
getopt
-o
hp:n:
-l
help
,path:,name
:
--
"
$@
"
)
options
=
$(
getopt
-o
hp:n:
S:
-l
help
,path:,name:,auth-key
:
--
"
$@
"
)
if
[
$?
-ne
0
]
;
then
usage
$(
basename
$0
)
exit
1
exit
1
fi
eval set
--
"
$options
"
...
...
@@ -141,7 +156,8 @@ do
case
"
$1
"
in
-h
|
--help
)
usage
$0
&&
exit
0
;;
-p
|
--path
)
path
=
$2
;
shift
2
;;
-n
|
--name
)
name
=
$2
;
shift
2
;;
-n
|
--name
)
name
=
$2
;
shift
2
;;
-S
|
--auth-key
)
auth_key
=
$2
;
shift
2
;;
--
)
shift
1
;
break
;;
*
)
break
;;
esac
...
...
@@ -166,6 +182,22 @@ if [ $0 == "/sbin/init" ]; then
exit
1
fi
# run dhcp?
if
[
-f
/run-dhcp
]
;
then
type
dhclient
if
[
$?
-ne
0
]
;
then
echo
"can't find dhclient"
exit
1
fi
touch
/etc/fstab
rm
-f
/dhclient.conf
cat
>
/dhclient.conf
<<
EOF
send host-name "<hostname>";
EOF
ifconfig eth0 up
dhclient eth0
-cf
/dhclient.conf
fi
exec
@LXCINITDIR@/lxc-init
--
/usr/sbin/sshd
exit
1
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