How to reload the ssh config file in Mac OS X via terminal
up vote
5
down vote
favorite
When I update my ssh config file so I can switch my current github account, the changes wont work properly unless I restart iTerm. I'm working on a script to automate the github account switch and I'd like to have the script reload the config settings in the updated config file. How can I achieve this?
macos bash ssh terminal
add a comment |
up vote
5
down vote
favorite
When I update my ssh config file so I can switch my current github account, the changes wont work properly unless I restart iTerm. I'm working on a script to automate the github account switch and I'd like to have the script reload the config settings in the updated config file. How can I achieve this?
macos bash ssh terminal
1
How, do you switch accounts? Do you usessh-agent
? Thessh_config
is read for every single invocation ofssh
.
– Jakuje
Nov 23 '16 at 8:44
Can you give us more detail about the config file? Also, could you define different hosts for the different github accounts, and avoid the reloading problem?
– JasKerr
Nov 24 '16 at 2:45
add a comment |
up vote
5
down vote
favorite
up vote
5
down vote
favorite
When I update my ssh config file so I can switch my current github account, the changes wont work properly unless I restart iTerm. I'm working on a script to automate the github account switch and I'd like to have the script reload the config settings in the updated config file. How can I achieve this?
macos bash ssh terminal
When I update my ssh config file so I can switch my current github account, the changes wont work properly unless I restart iTerm. I'm working on a script to automate the github account switch and I'd like to have the script reload the config settings in the updated config file. How can I achieve this?
macos bash ssh terminal
macos bash ssh terminal
asked Nov 22 '16 at 22:20
Daniel Jacobson
150127
150127
1
How, do you switch accounts? Do you usessh-agent
? Thessh_config
is read for every single invocation ofssh
.
– Jakuje
Nov 23 '16 at 8:44
Can you give us more detail about the config file? Also, could you define different hosts for the different github accounts, and avoid the reloading problem?
– JasKerr
Nov 24 '16 at 2:45
add a comment |
1
How, do you switch accounts? Do you usessh-agent
? Thessh_config
is read for every single invocation ofssh
.
– Jakuje
Nov 23 '16 at 8:44
Can you give us more detail about the config file? Also, could you define different hosts for the different github accounts, and avoid the reloading problem?
– JasKerr
Nov 24 '16 at 2:45
1
1
How, do you switch accounts? Do you use
ssh-agent
? The ssh_config
is read for every single invocation of ssh
.– Jakuje
Nov 23 '16 at 8:44
How, do you switch accounts? Do you use
ssh-agent
? The ssh_config
is read for every single invocation of ssh
.– Jakuje
Nov 23 '16 at 8:44
Can you give us more detail about the config file? Also, could you define different hosts for the different github accounts, and avoid the reloading problem?
– JasKerr
Nov 24 '16 at 2:45
Can you give us more detail about the config file? Also, could you define different hosts for the different github accounts, and avoid the reloading problem?
– JasKerr
Nov 24 '16 at 2:45
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
You may want to look at the Atlassian documentation on using multiple identities. A case like the one I think you're describing - switching accounts - may be best handled with an SSH config file that accommodates multiple accounts simultaneously instead of scripting.
They provide the following example for the config
file at ~/.ssh/config:
# Default GitHub user
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/personalid
# Work user account
Host bitbucket.org
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/workid
1
Note you could also use differentHost
nicknames for the sameHostName
, with differentIdentityFile
s for each:Host github-charlie
,Host github-sam
– jpaugh
Feb 5 at 14:56
add a comment |
up vote
0
down vote
While I was looking for a way to 'refresh' the file I realised what I was actually looking for was a way to auto complete the command,
Refreshing was not necessary as @Jakuje above mentions
For those interested the auto complete script is:
complete -o default -o nospace -W "$(grep "^Host" $HOME/.ssh/config | cut -d" " -f2)" scp sftp ssh
Which I found here.
Add the above script to .bash_profile
and then run source .bash_profile
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You may want to look at the Atlassian documentation on using multiple identities. A case like the one I think you're describing - switching accounts - may be best handled with an SSH config file that accommodates multiple accounts simultaneously instead of scripting.
They provide the following example for the config
file at ~/.ssh/config:
# Default GitHub user
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/personalid
# Work user account
Host bitbucket.org
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/workid
1
Note you could also use differentHost
nicknames for the sameHostName
, with differentIdentityFile
s for each:Host github-charlie
,Host github-sam
– jpaugh
Feb 5 at 14:56
add a comment |
up vote
0
down vote
You may want to look at the Atlassian documentation on using multiple identities. A case like the one I think you're describing - switching accounts - may be best handled with an SSH config file that accommodates multiple accounts simultaneously instead of scripting.
They provide the following example for the config
file at ~/.ssh/config:
# Default GitHub user
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/personalid
# Work user account
Host bitbucket.org
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/workid
1
Note you could also use differentHost
nicknames for the sameHostName
, with differentIdentityFile
s for each:Host github-charlie
,Host github-sam
– jpaugh
Feb 5 at 14:56
add a comment |
up vote
0
down vote
up vote
0
down vote
You may want to look at the Atlassian documentation on using multiple identities. A case like the one I think you're describing - switching accounts - may be best handled with an SSH config file that accommodates multiple accounts simultaneously instead of scripting.
They provide the following example for the config
file at ~/.ssh/config:
# Default GitHub user
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/personalid
# Work user account
Host bitbucket.org
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/workid
You may want to look at the Atlassian documentation on using multiple identities. A case like the one I think you're describing - switching accounts - may be best handled with an SSH config file that accommodates multiple accounts simultaneously instead of scripting.
They provide the following example for the config
file at ~/.ssh/config:
# Default GitHub user
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/personalid
# Work user account
Host bitbucket.org
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/workid
answered May 16 '17 at 17:39
user2623888
1
1
1
Note you could also use differentHost
nicknames for the sameHostName
, with differentIdentityFile
s for each:Host github-charlie
,Host github-sam
– jpaugh
Feb 5 at 14:56
add a comment |
1
Note you could also use differentHost
nicknames for the sameHostName
, with differentIdentityFile
s for each:Host github-charlie
,Host github-sam
– jpaugh
Feb 5 at 14:56
1
1
Note you could also use different
Host
nicknames for the same HostName
, with different IdentityFile
s for each: Host github-charlie
, Host github-sam
– jpaugh
Feb 5 at 14:56
Note you could also use different
Host
nicknames for the same HostName
, with different IdentityFile
s for each: Host github-charlie
, Host github-sam
– jpaugh
Feb 5 at 14:56
add a comment |
up vote
0
down vote
While I was looking for a way to 'refresh' the file I realised what I was actually looking for was a way to auto complete the command,
Refreshing was not necessary as @Jakuje above mentions
For those interested the auto complete script is:
complete -o default -o nospace -W "$(grep "^Host" $HOME/.ssh/config | cut -d" " -f2)" scp sftp ssh
Which I found here.
Add the above script to .bash_profile
and then run source .bash_profile
add a comment |
up vote
0
down vote
While I was looking for a way to 'refresh' the file I realised what I was actually looking for was a way to auto complete the command,
Refreshing was not necessary as @Jakuje above mentions
For those interested the auto complete script is:
complete -o default -o nospace -W "$(grep "^Host" $HOME/.ssh/config | cut -d" " -f2)" scp sftp ssh
Which I found here.
Add the above script to .bash_profile
and then run source .bash_profile
add a comment |
up vote
0
down vote
up vote
0
down vote
While I was looking for a way to 'refresh' the file I realised what I was actually looking for was a way to auto complete the command,
Refreshing was not necessary as @Jakuje above mentions
For those interested the auto complete script is:
complete -o default -o nospace -W "$(grep "^Host" $HOME/.ssh/config | cut -d" " -f2)" scp sftp ssh
Which I found here.
Add the above script to .bash_profile
and then run source .bash_profile
While I was looking for a way to 'refresh' the file I realised what I was actually looking for was a way to auto complete the command,
Refreshing was not necessary as @Jakuje above mentions
For those interested the auto complete script is:
complete -o default -o nospace -W "$(grep "^Host" $HOME/.ssh/config | cut -d" " -f2)" scp sftp ssh
Which I found here.
Add the above script to .bash_profile
and then run source .bash_profile
answered Sep 3 at 15:50
Tomos Williams
1011
1011
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2fsuperuser.com%2fquestions%2f1148766%2fhow-to-reload-the-ssh-config-file-in-mac-os-x-via-terminal%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
1
How, do you switch accounts? Do you use
ssh-agent
? Thessh_config
is read for every single invocation ofssh
.– Jakuje
Nov 23 '16 at 8:44
Can you give us more detail about the config file? Also, could you define different hosts for the different github accounts, and avoid the reloading problem?
– JasKerr
Nov 24 '16 at 2:45