First of all, edit/add the SSH configuration file $HOME/.ssh/config with content like the following:
Host hpc
HostName hpc.example.com
Port 21
User foo
HostName hpc.example.com
Port 21
User foo
chmod 600 $HOME/.ssh/config
Here we have set up an alias 'hpc' for the full remote machine address and 'ssh hpc' can initialize the login process without using the lengthy one 'ssh foo@hpc.example.com'. But we still need to type in password to get access.
Let us next set up passwordless ssh login.
Make a pair of private and public keys by:
ssh-keygen -t rsa
Note that passphrase should be left empty when prompted. By default, two files id_rsa.pub (the public key) and id_rsa (the private key) will be generated in the folder ~/.ssh/.
Copy the public key to the remote machine and then append its content to file ~/.ssh/authorized_keys:
ssh hpc cat id_rsa.pub >>~/.ssh/authorized_keys <~/.ssh/id_rsa.pub
Finally, change the file mode of the private key file so that other users can not meddle with it:
chmod 600 ~/.ssh/id_rsa
Now everything is set and we should be able to access the remote server without a password:
ssh hpc
Let us next set up passwordless ssh login.
Make a pair of private and public keys by:
ssh-keygen -t rsa
Note that passphrase should be left empty when prompted. By default, two files id_rsa.pub (the public key) and id_rsa (the private key) will be generated in the folder ~/.ssh/.
Copy the public key to the remote machine and then append its content to file ~/.ssh/authorized_keys:
ssh hpc cat id_rsa.pub >>~/.ssh/authorized_keys <~/.ssh/id_rsa.pub
Finally, change the file mode of the private key file so that other users can not meddle with it:
chmod 600 ~/.ssh/id_rsa
Now everything is set and we should be able to access the remote server without a password:
ssh hpc
No comments:
Post a Comment