The documentation for SSH configuration and set up will be changed to show the use of the following solution.
The change here is using the cat command instead of the cp command previously included in the documentation.
This allows the change to be appended to existing files, or new files written if not present and avoids file overwrite problems.
We need to first check the home directory for the root, sudo root or dradmin OS user involved. We're seeking whether or not these two files exist in the users ~/.ssh directory.
The simple method to check, without having to know the users home directory, is the following.
- Log in to the host in a terminal window as the target user.
- Run the command which will list (ls) all files with ownership and permissions (-al) in the users home directory (~) in the hidden .ssh directory.
- Sample output for a root user, and for a default example dradmin user.
total 24
drwx------. 2 root root 132 Sep 19 2019 .
dr-xr-x---. 7 root root 4096 Sep 20 2019 ..
-rw-------. 1 root root 1251 Sep 19 2019 authorized_keys
-rw-r--r-- 1 root root 417 Sep 19 2019 authorized_keys2
-rw-------. 1 root root 0 Sep 17 2019 authorized_keys.orig
-rw------- 1 root root 1675 Sep 19 2019 id_rsa
-rw-r--r-- 1 root root 417 Sep 19 2019 id_rsa.pub
-rw-r--r-- 1 root root 753 Sep 19 2019 known_hosts
total 20
drwx------ 2 dradmin verticadba 104 Sep 20 2019 .
drwx------ 6 dradmin verticadba 177 Sep 30 2019 ..
-rw-r--r-- 1 dradmin verticadba 381 Sep 20 2019 authorized_keys
-rw-r--r-- 1 dradmin verticadba 381 Sep 20 2019 authorized_keys2
-rw------- 1 dradmin verticadba 1679 Sep 20 2019 id_rsa
-rw------- 1 dradmin verticadba 381 Sep 20 2019 id_rsa.pub
-rw-r--r-- 1 dradmin verticadba 346 Sep 20 2019 known_hosts
Scenario 1: The id_rsa and id_rsa.pub files are not present in the users ~/.ssh directory.
If the id_rsa and id_rsa.pub files are not present in the users ~/.ssh/ directory perform the following steps.
- Run these three commands:
- ssh-keygen -N "" -t rsa -f ~/.ssh/id_rsa
- cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys2
- chmod 644 ~/.ssh/authorized_keys2
- cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
- chmod 644 ~/.ssh/authorized_keys
- Run the following, once each for all hosts you want to log into.
Scenario 2: The id_rsa and id_rsa.pub files are already present in the users ~/.ssh directory.
If the id_rsa and id_rsa.pub files are present in the users ~/.ssh/ directory perform the following steps.
- Run these commands:
- cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
- cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys2
- Run the following to all hosts you want to log into.