Its quite easy to set up keys following a tutorial as this. But once you have it generated, it could be quite a hassle to do all the required steps on every machine you need to access. Especially if you find your self having to access many machines, often with more than one user.
Anyways, here's a nice bash-function to set up your keys for you.
function remember_me {
ssh $1 'mkdir -p .ssh && touch .ssh/authorized_keys \
&& chmod 0700 .ssh \
&& chmod 0600 .ssh/authorized_keys \
&& cat >> .ssh/authorized_keys' <~/.ssh/id_rsa.pub
}
Add this to your ~/.bashrc or ~/.bash_profile file. Reload your settings using
source ~/.bashrc
or equivalent. Then just type
remember_me youruser@your.domain.com
You will be prompted for your credentials and then. BAM! Your keys are set up.On the subject; an other related tip is to setup your servers as aliases adding something like
alias server="ssh youruser@your.domain.com"
to your ~/.bashrc file.If you set up the ssh-keys correctly you just have to type
server
And there you are. Now you're on the remote server.
No comments:
Post a Comment