Doing an ssh-add upon ssh/slogin if key is not in ssh-agent?Why is ssh-add adding duplicate identity keys?Is there a graphical ssh-agent in 10.04 LTS Server?How to get OpenSSH to use ksshaskpass under KDE?ssh-agent is not used when ssh is launched from panel launcher (via `gnome-terminal --command`)Using PKCS#8 encrypted private keys w/ ssh-agentssh-agent running but not working when logged in using PuTTYHow to avoid typing ssh-add everytimeWhy can't I interact with my ssh-agent? (e.g. ssh-add -D doesn't work)Ubuntu 16.04 ssh-add without ssh-agent?Use gnome-keyring as ssh agent instead of openssh
Why is this sentence grammatical?
What was the ultimate objective of The Party in 1984?
Make 2019 with single digits
Assign every word from a line to a variable
How much would a 1 foot tall human weigh?
Where is it? - The Google Earth Challenge Ep. 3
Can a character with good/neutral alignment attune to a sentient magic item with evil alignment?
Why any infinite sequence of real functions can be generated from a finite set through composition?
geschafft or geschaffen? which one is past participle of schaffen?
Are space camera sensors usually round, or square?
International Orange?
Would it be unbalanced to increase a druid's number of uses of Wild Shape based on level?
How do I add Applications to Favorites in Finder' Sidebar?
What is the mathematical notation for rounding a given number to the nearest integer?
Importance of the current postdoc advisor's letter in TT job search
Insight into cavity resonators
Meaning of Swimming their horses
Permutations in Disguise
Masking out non-linear shapes on canvas
Test to know when to use GLM over Linear Regression?
What organs or modifications would be needed for a life biological creature not to require sleep?
Python web-scraper to download table of transistor counts from Wikipedia
Block diagram vs flow chart?
How clean are pets?
Doing an ssh-add upon ssh/slogin if key is not in ssh-agent?
Why is ssh-add adding duplicate identity keys?Is there a graphical ssh-agent in 10.04 LTS Server?How to get OpenSSH to use ksshaskpass under KDE?ssh-agent is not used when ssh is launched from panel launcher (via `gnome-terminal --command`)Using PKCS#8 encrypted private keys w/ ssh-agentssh-agent running but not working when logged in using PuTTYHow to avoid typing ssh-add everytimeWhy can't I interact with my ssh-agent? (e.g. ssh-add -D doesn't work)Ubuntu 16.04 ssh-add without ssh-agent?Use gnome-keyring as ssh agent instead of openssh
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
When I'm running Gnome, ssh-agent will run ssh-add upon slogin/ssh if the identity is not loaded. I want to mimic this behavior on remote shells, but everything I find suggests to run ssh-add upon login. I only want to run ssh-add if I subsequently run slogin/ssh on the remote shell, not every time I login.
ssh-agent
add a comment
|
When I'm running Gnome, ssh-agent will run ssh-add upon slogin/ssh if the identity is not loaded. I want to mimic this behavior on remote shells, but everything I find suggests to run ssh-add upon login. I only want to run ssh-add if I subsequently run slogin/ssh on the remote shell, not every time I login.
ssh-agent
add a comment
|
When I'm running Gnome, ssh-agent will run ssh-add upon slogin/ssh if the identity is not loaded. I want to mimic this behavior on remote shells, but everything I find suggests to run ssh-add upon login. I only want to run ssh-add if I subsequently run slogin/ssh on the remote shell, not every time I login.
ssh-agent
When I'm running Gnome, ssh-agent will run ssh-add upon slogin/ssh if the identity is not loaded. I want to mimic this behavior on remote shells, but everything I find suggests to run ssh-add upon login. I only want to run ssh-add if I subsequently run slogin/ssh on the remote shell, not every time I login.
ssh-agent
ssh-agent
asked Feb 18 '11 at 17:55
Pete AshdownPete Ashdown
1,7901 gold badge11 silver badges13 bronze badges
1,7901 gold badge11 silver badges13 bronze badges
add a comment
|
add a comment
|
4 Answers
4
active
oldest
votes
I worked out a solution for this via the bash shell.
Add to .bashrc:
check-ssh-add()
if [ "$DESKTOP_SESSION" == "" ]; then
if [[ `ssh-add -l` != *id_?sa* ]]; then
ssh-add -t 5h ## 5 hour ssh-agent expiration
fi
fi
slogin()
check-ssh-add
/usr/bin/slogin $@
ssh()
check-ssh-add
/usr/bin/ssh $@
scp()
check-ssh-add
/usr/bin/scp $@
sftp()
check-ssh-add
/usr/bin/sftp $@
add a comment
|
There's actually an even simpler way. ssh-add -l
returns true (0) if there are keys and false (1) otherwise, so your first function can be replaced with this:
check-ssh-add()
if ! ssh-add -l >/dev/null; then
ssh-add -t 5h
fi
add a comment
|
Even simpler in the «this is an interactive session» part add
ssh-add -l &> /dev/null || ssh-add ~/.ssh/my_id
add a comment
|
Newer versions of OpenSSH can add the key to the agent on first use, if you enable AddKeysToAgent yes
in your ~/.ssh/config
.
(I've learned this from https://superuser.com/a/1114257/42546. I'm not sure what the proper StackOverflow etiquette is for coping answers across various StackExchange sites.)
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f27014%2fdoing-an-ssh-add-upon-ssh-slogin-if-key-is-not-in-ssh-agent%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
I worked out a solution for this via the bash shell.
Add to .bashrc:
check-ssh-add()
if [ "$DESKTOP_SESSION" == "" ]; then
if [[ `ssh-add -l` != *id_?sa* ]]; then
ssh-add -t 5h ## 5 hour ssh-agent expiration
fi
fi
slogin()
check-ssh-add
/usr/bin/slogin $@
ssh()
check-ssh-add
/usr/bin/ssh $@
scp()
check-ssh-add
/usr/bin/scp $@
sftp()
check-ssh-add
/usr/bin/sftp $@
add a comment
|
I worked out a solution for this via the bash shell.
Add to .bashrc:
check-ssh-add()
if [ "$DESKTOP_SESSION" == "" ]; then
if [[ `ssh-add -l` != *id_?sa* ]]; then
ssh-add -t 5h ## 5 hour ssh-agent expiration
fi
fi
slogin()
check-ssh-add
/usr/bin/slogin $@
ssh()
check-ssh-add
/usr/bin/ssh $@
scp()
check-ssh-add
/usr/bin/scp $@
sftp()
check-ssh-add
/usr/bin/sftp $@
add a comment
|
I worked out a solution for this via the bash shell.
Add to .bashrc:
check-ssh-add()
if [ "$DESKTOP_SESSION" == "" ]; then
if [[ `ssh-add -l` != *id_?sa* ]]; then
ssh-add -t 5h ## 5 hour ssh-agent expiration
fi
fi
slogin()
check-ssh-add
/usr/bin/slogin $@
ssh()
check-ssh-add
/usr/bin/ssh $@
scp()
check-ssh-add
/usr/bin/scp $@
sftp()
check-ssh-add
/usr/bin/sftp $@
I worked out a solution for this via the bash shell.
Add to .bashrc:
check-ssh-add()
if [ "$DESKTOP_SESSION" == "" ]; then
if [[ `ssh-add -l` != *id_?sa* ]]; then
ssh-add -t 5h ## 5 hour ssh-agent expiration
fi
fi
slogin()
check-ssh-add
/usr/bin/slogin $@
ssh()
check-ssh-add
/usr/bin/ssh $@
scp()
check-ssh-add
/usr/bin/scp $@
sftp()
check-ssh-add
/usr/bin/sftp $@
answered Feb 20 '11 at 19:46
Pete AshdownPete Ashdown
1,7901 gold badge11 silver badges13 bronze badges
1,7901 gold badge11 silver badges13 bronze badges
add a comment
|
add a comment
|
There's actually an even simpler way. ssh-add -l
returns true (0) if there are keys and false (1) otherwise, so your first function can be replaced with this:
check-ssh-add()
if ! ssh-add -l >/dev/null; then
ssh-add -t 5h
fi
add a comment
|
There's actually an even simpler way. ssh-add -l
returns true (0) if there are keys and false (1) otherwise, so your first function can be replaced with this:
check-ssh-add()
if ! ssh-add -l >/dev/null; then
ssh-add -t 5h
fi
add a comment
|
There's actually an even simpler way. ssh-add -l
returns true (0) if there are keys and false (1) otherwise, so your first function can be replaced with this:
check-ssh-add()
if ! ssh-add -l >/dev/null; then
ssh-add -t 5h
fi
There's actually an even simpler way. ssh-add -l
returns true (0) if there are keys and false (1) otherwise, so your first function can be replaced with this:
check-ssh-add()
if ! ssh-add -l >/dev/null; then
ssh-add -t 5h
fi
edited Jan 4 '16 at 9:32
HighCommander4
1155 bronze badges
1155 bronze badges
answered Dec 18 '13 at 11:23
RelsquiRelsqui
711 silver badge2 bronze badges
711 silver badge2 bronze badges
add a comment
|
add a comment
|
Even simpler in the «this is an interactive session» part add
ssh-add -l &> /dev/null || ssh-add ~/.ssh/my_id
add a comment
|
Even simpler in the «this is an interactive session» part add
ssh-add -l &> /dev/null || ssh-add ~/.ssh/my_id
add a comment
|
Even simpler in the «this is an interactive session» part add
ssh-add -l &> /dev/null || ssh-add ~/.ssh/my_id
Even simpler in the «this is an interactive session» part add
ssh-add -l &> /dev/null || ssh-add ~/.ssh/my_id
answered Mar 16 '15 at 14:25
user1458574user1458574
111 bronze badge
111 bronze badge
add a comment
|
add a comment
|
Newer versions of OpenSSH can add the key to the agent on first use, if you enable AddKeysToAgent yes
in your ~/.ssh/config
.
(I've learned this from https://superuser.com/a/1114257/42546. I'm not sure what the proper StackOverflow etiquette is for coping answers across various StackExchange sites.)
add a comment
|
Newer versions of OpenSSH can add the key to the agent on first use, if you enable AddKeysToAgent yes
in your ~/.ssh/config
.
(I've learned this from https://superuser.com/a/1114257/42546. I'm not sure what the proper StackOverflow etiquette is for coping answers across various StackExchange sites.)
add a comment
|
Newer versions of OpenSSH can add the key to the agent on first use, if you enable AddKeysToAgent yes
in your ~/.ssh/config
.
(I've learned this from https://superuser.com/a/1114257/42546. I'm not sure what the proper StackOverflow etiquette is for coping answers across various StackExchange sites.)
Newer versions of OpenSSH can add the key to the agent on first use, if you enable AddKeysToAgent yes
in your ~/.ssh/config
.
(I've learned this from https://superuser.com/a/1114257/42546. I'm not sure what the proper StackOverflow etiquette is for coping answers across various StackExchange sites.)
answered Apr 15 at 11:21
Marius GedminasMarius Gedminas
7,6347 gold badges39 silver badges47 bronze badges
7,6347 gold badges39 silver badges47 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f27014%2fdoing-an-ssh-add-upon-ssh-slogin-if-key-is-not-in-ssh-agent%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown