简体   繁体   中英

adding ssh key to a user from a bash script being run as root

I want to give a user access to a git repository without him having to enter a password.

Lets say I have a bash script that does this:

eval `ssh-agent -s`
ssh-add ~/.ssh/id_rsa

This script is being run with sudo ./script.sh I would I add the ssh key for a user instead of root?

您可以将su -c <command> $SUID_USER与命令一起使用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM