Skip to content

Commit 3844f86

Browse files
#20 - fix location of ssh authorized keys
1 parent 2d9db0d commit 3844f86

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

sagemaker_ssh_helper/sm-connect-ssh-proxy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ aws --no-cli-pager ssm send-command \
3636
--parameters "commands=[
3737
'id',
3838
'aws sts get-caller-identity',
39-
'mkdir -p /root/.ssh/authorized_keys.d/',
40-
'aws s3 cp --recursive ${SSH_AUTHORIZED_KEYS} /root/.ssh/authorized_keys.d/',
41-
'cat /root/.ssh/authorized_keys.d/* > /root/.ssh/authorized_keys',
42-
'cat /root/.ssh/authorized_keys'
39+
'mkdir -p /etc/ssh/authorized_keys.d/',
40+
'aws s3 cp --recursive ${SSH_AUTHORIZED_KEYS} /etc/ssh/authorized_keys.d/',
41+
'cat /etc/ssh/authorized_keys.d/* > /etc/ssh/authorized_keys',
42+
'cat /etc/ssh/authorized_keys'
4343
]" \
4444
--no-paginate --output text
4545

sagemaker_ssh_helper/sm-ssh-ide

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ EOF
6363
echo "startxfce4" > ~/.xsession
6464
chmod +x ~/.xsession
6565

66-
sed -i~~ -e 's/^\#ClientAliveInterval 0$/ClientAliveInterval 15/' /etc/ssh/sshd_config
66+
sed -i -e 's~^ClientAliveInterval~#ClientAliveInterval~' /etc/ssh/sshd_config
67+
echo "ClientAliveInterval 15" >> /etc/ssh/sshd_config
68+
69+
sed -i -e 's~^AuthorizedKeysFile~#AuthorizedKeysFile~' /etc/ssh/sshd_config
70+
echo "AuthorizedKeysFile /etc/ssh/authorized_keys" >> /etc/ssh/sshd_config
6771

6872
elif [[ "$1" == "set-jb-license-server" ]]; then
6973

sagemaker_ssh_helper/sm-start-ssh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ ps wwwe -p 1 | tail -1
3434
sed -i -e 's~^PermitRootLogin~#PermitRootLogin~' /etc/ssh/sshd_config
3535
echo PermitRootLogin yes >> /etc/ssh/sshd_config
3636

37+
sed -i -e 's~^AuthorizedKeysFile~#AuthorizedKeysFile~' /etc/ssh/sshd_config
38+
echo "AuthorizedKeysFile /etc/ssh/authorized_keys" >> /etc/ssh/sshd_config
39+
3740
# Start SSH server
3841
if _is_centos; then
3942
# NOTE: systemctl will not work in CentOS SageMaker container (e.g. Spark processing) because lack of

0 commit comments

Comments
 (0)