Comments (2)
I experimented with this and the below worked for me. Need to run the ssh-add
as sudo and keep environment variables set with -e
.
#!/bin/bash
set -e
sudo -u ec2-user -i <<'EOF'
unset SUDO_UID
echo "Activate agent"
cd /home/ec2-user
eval `ssh-agent -s`
ssh-add /home/ec2-user/SageMaker/.ssh/id_rsa
echo "Check for key"
ps aux | grep ssh
EOF
from amazon-sagemaker-notebook-instance-lifecycle-config-samples.
? "set -e" doesn't "keep environment variables set". It turns on the "errexit" (error exit) flag, which will cause the whole script to terminate immediately if any of the commands it runs signals an error.
I don't know why you are unsetting SUDO_UID
; ssh-agent
doesn't have any references to that. And SUDO_USER will still be set to the original username.
Note that ssh-agent
is for keeping keys around in memory so (1) you can forward the agent connection for use on machines that don't have the key on their file systems, and (2) you don't have to type a passphrase every time you run an ssh command. If the key is already in a file on the instance and not passphrase protected, you don't need ssh-agent
; just tell ssh to use that file (e.g. by putting IdentityFile /home/ec2-user/SageMaker/.ssh/id_rsa
in /home/ec2-user/.ssh/config).
from amazon-sagemaker-notebook-instance-lifecycle-config-samples.
Related Issues (20)
- Updated autostop script not working HOT 3
- execute-notebook-on-startup [Script doesn't work] HOT 1
- [Question] : Setup multiple life cycle configurations with the same instance HOT 1
- auto-stop-idle/on-start.sh notebooks built on aws2 can't "find" Python HOT 3
- Following env variable example has Jupyter return 500 code HOT 3
- persistent-conda-ebs/on-create.sh keeps timing out HOT 1
- Are there examples for SageMaker Studio? HOT 2
- Lifecycle config cannot run notebook that imports sagemaker, boto3 libraries HOT 2
- Auto Stop idle script giving error HOT 3
- restart jupyter-server : command not found HOT 6
- update use-persisted-conda HOT 1
- execute-notebook-on-startup -
- persisting enviroment only supports python 3.7.11? HOT 2
- Auto Stop Idle Policy hangs on Amazon Linux 2 Instance (notebook-al2-v1) HOT 1
- Life cycle config took longer than 5 minutes HOT 1
- studio lifecycle HOT 2
- More Examples HOT 1
- auto-stop-idle/autostop.py ignores open terminal sessions HOT 4
- persistent-conda-ebs doen't allow to install more libraries?
- [question] How to make a lifecycle configuration default for all new notebooks? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amazon-sagemaker-notebook-instance-lifecycle-config-samples.