Assuming both local (your "client" PC) and remote (Ubuntu "server") computers are running some decent version of Linux or UNIX (or Cygwin), the standard procedure is:
On the client (local user at local computer) run:
$ ssh-keygen
Append the contents of the file ~/.ssh/id_rsa.pub
created on the client to the end of the file ~/.ssh/authorized_keys
on the remote user at the remote server.
Create the remote folder ~/.ssh
and the file, if it does not exist. Run also the following on the remote user at the remote server:
$ chmod 600 ~/.ssh/authorized_keys
$ chmod 700 ~/.ssh
The above procedure will create a passwordless ssh
, scp
, sftp
, etc. access from the local user & computer to the remote user & computer. It should be repeated for each local user & computer to remote user & computer combination.
Note that the id and name of the local user is not related to the id and name of the remote user. They can be anything, however the ssh
command defaults to the same user name at the remote computer if only the remote computer is specified (e.g. ssh remote_computer
). If they are different, then the remote user name should be specified at the command line as well (e.g. ssh remote_user@remote_computer
).
The files created by ssh-keygen
on the local user's home directory at the local computer are these:
File Location and Name |
Permissions |
Usage |
~/.ssh/id_rsa |
0600/-rw------- |
Contains your private key. Nobody should have access to this file except your user. |
~/.ssh/id_rsa.pub |
0644/-rw-r--r-- |
Contains your public key. Can be freely appended to ~/.ssh/authorized_keys file(s) on other computers that your local user needs to access. |
The file at the remote user should be like this:
File Location and Name |
Permissions |
Usage |
~/.ssh/authorized_keys |
0600/-rw------- |
Contains all the public keys that will allow clients to be connected to this user from other computers. |
For more information, see man ssh
and man sshd
.