mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
Updated README.md and added the add_ssh_key_to_host shell function
This commit is contained in:
parent
278616e952
commit
85962059de
2 changed files with 34 additions and 0 deletions
|
|
@ -64,6 +64,8 @@ There are some helpful functions to maintain things:
|
||||||
|
|
||||||
config_omzs_for_host # stubs out a hierarchy for a specified remote hostname
|
config_omzs_for_host # stubs out a hierarchy for a specified remote hostname
|
||||||
|
|
||||||
|
add_ssh_key_to_host # copy your .ssh/id_rsa.pub or id_dsa.pub key to a remote host
|
||||||
|
|
||||||
propagate_omzs_to_host # copies your ~/.oh-my-zsh directory to a remote host
|
propagate_omzs_to_host # copies your ~/.oh-my-zsh directory to a remote host
|
||||||
|
|
||||||
load_omzs_on_alias # run this on a remote host to setup an alias 'omzs' to load oh-my-zsh
|
load_omzs_on_alias # run this on a remote host to setup an alias 'omzs' to load oh-my-zsh
|
||||||
|
|
@ -74,6 +76,8 @@ There are some helpful functions to maintain things:
|
||||||
|
|
||||||
* `config_omzs_for_host` - "Usage: config_omzs_for_host HOSTNAME" - creates a directory structure for your remote machine and stubs out a few .sh files
|
* `config_omzs_for_host` - "Usage: config_omzs_for_host HOSTNAME" - creates a directory structure for your remote machine and stubs out a few .sh files
|
||||||
|
|
||||||
|
* `add_ssh_key_to_host` - "Usage: add_ssh_key_to_host [user@]HOSTNAME" - Add your public SSH key to a remote host. You may have to enter your password up to 3 times. After that it will be passwordless if the remote sshd server is setup to allow it
|
||||||
|
|
||||||
* The `load_omzs_on_alias` function is nice if others also use that account and you don't want to force them to use your oh-my-zsh settings.
|
* The `load_omzs_on_alias` function is nice if others also use that account and you don't want to force them to use your oh-my-zsh settings.
|
||||||
|
|
||||||
* `propagate_omzs_to_host` - "Usage: propagate_omzs_to_host [user@]HOSTNAME" - compresses your `~/.oh-my-zsh` directory, uploads it to the specified host account, decompresses it and reminds you to run one of `load_omzs_on_alias` or `load_omzs_on_login`
|
* `propagate_omzs_to_host` - "Usage: propagate_omzs_to_host [user@]HOSTNAME" - compresses your `~/.oh-my-zsh` directory, uploads it to the specified host account, decompresses it and reminds you to run one of `load_omzs_on_alias` or `load_omzs_on_login`
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,36 @@ function load_omzs_on_alias {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Add your public SSH key to a remote host
|
||||||
|
# You may have to enter your password up to 3 times.
|
||||||
|
# After that it will be passwordless if the remote sshd server is setup to allow it
|
||||||
|
function add_ssh_key_to_host {
|
||||||
|
if [[ $# -lt 1 ]]; then
|
||||||
|
echo "Usage: add_ssh_key_to_host [user@]HOSTNAME"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# First check that the account has an authorized_keys file
|
||||||
|
ssh_dir='~/.ssh'
|
||||||
|
authorized_keys_file='authorized_keys'
|
||||||
|
output=`ssh $1 "ls -1 $ssh_dir" stderr 2> /dev/null`
|
||||||
|
if [[ "$output" =~ "authorized_keys" ]]; then
|
||||||
|
echo "- appending [$1]: $ssh_dir/$authorized_keys_file"
|
||||||
|
else
|
||||||
|
echo "- creating [$1]: $ssh_dir/$authorized_keys_file"
|
||||||
|
output=`ssh $1 "mkdir -p $ssh_dir && touch $ssh_dir/$authorized_keys_file && chmod 700 $ssh_dir && chmod 600 $ssh_dir/$authorized_keys_file"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use DSA key by default, fallback to RSA key
|
||||||
|
if [[ -r ~/.ssh/id_dsa.pub ]]; then
|
||||||
|
echo "- using your DSA key"
|
||||||
|
cat ~/.ssh/id_dsa.pub | ssh $1 "cat >> $ssh_dir/$authorized_keys_file"
|
||||||
|
elif [[ -r ~/.ssh/id_rsa.pub ]]; then
|
||||||
|
echo "- using your RSA key"
|
||||||
|
cat ~/.ssh/id_rsa.pub | ssh $1 "cat >> $ssh_dir/$authorized_keys_file"
|
||||||
|
fi
|
||||||
|
echo "- ssh logins should now be passwordless on [$1]"
|
||||||
|
}
|
||||||
|
|
||||||
# Propagate your environment system to a remote host
|
# Propagate your environment system to a remote host
|
||||||
function propagate_omzs_to_host {
|
function propagate_omzs_to_host {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue