In a safe location, run the following command to generate your key pair:
ssh-keygen -b 4096 -t rsaYou'll immediately be prompted to choose a file name for the key pair. Most commonly, the string 'identity' is used and I suggest using that. Following that, you'll need to enter a pass phrase twice. The end result of running the above command will leave you with two files: 'identity', and 'identity.pub.' One is private, you should just keep this file on your home machine, laptop, or flash drive and the other is public.
Next, back up your current '~/.ssh' folder and create a new one to house your fresh keys.
mv ~/.ssh ~/.ssh-oldOnce your keys are in place you can run the following command to 'add' your keys and ensure that everything has gone according to plan. Running this will prompt you for your pass phrase.
mkdir ~/.ssh
mv identity* ~/.ssh/
ssh-addNow, we need to set up the public part of your key on any remote hosts you want to access without typing your password. If you have an NFS mount on those hosts (like CSEE) you just need to do this in your home directory. ssh into the server or machine in question and if '~/.ssh' does not exist create it. Once created, go to '~/.ssh' and create the file 'authorized_keys'.
cd ~/.ssh && touch authorized_keysFinally, copy the contents of your 'identity.pub' file into 'authorized_keys' on the remote host. The next time you authenticate (ensuring that you've used 'ssh-add' in advance) you won't need to enter your password.
No comments:
Post a Comment