![]() In case the script runs before you ever manually ssh in, though, you can add the entire large code block above to the script instead, so that it will prompt you to start the ssh-agent right there and let you type in your ssh keys right then. That simply tells your script to use the already-open ssh socket which you opened when you manually ssh-ed in. Then, to give any other script access to this agent, so that the script can use the keys, for instance, to push or pull to or from a GitHub code repo, add this to your script: export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock This will automatically start your ssh-agent and add default keys once per reboot whenever you ssh into your remote server. # see if any key files are already added to the ssh-agent, and if not, add themĮcho "No ssh keys have been added to your 'ssh-agent' since the last reboot. ![]() Ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sockĮxport SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock # for instance, will automatically start and manage the `ssh-agent` for you instead.Įcho "'ssh-agent' has not been started since the last reboot. ![]() # log into this machine, however, there is no need to do this, as Ubuntu's Gnome window manager, # into other machines or servers, such as to push code to GitHub over ssh. # remote ssh server development machine that you generally ssh into, and from which you must ssh # This is recommended to be added to your ~/.bash_aliases (preferred) or ~/.bashrc file on any In your server's ~/.bashrc or ~/.bash_aliases file, add this: # Auto-start the ssh agent and add necessary keys once per reboot. It is based on this answer here, but has my modifications. In case this is what you want, this works perfectly. ![]() This is a bit of a security risk as well, but is a tradeoff between convenience and security and is better than removing your ssh password entirely. Even better, you might want to share your ssh-agent socket with all processes so that if one process adds some keys, they are accessible to you and all other processes later. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |