1

I have this script that I am trying to execute on my machine Ubuntu 14.04, which indicates that I should Manage the ssh keys on servers to avoid entering password each time, which I didn't know how to, and the execution keeps asking me for a password (then I type the computer password) but it gives that the permission was denied,

As mentionned in the script, my machine will be both the server and client

Would you please help me about what to do, how should I configure the ssh connexion?

THANKS

1 Answers1

0

In your case "Server" and "Client" are that same computer.

Client side settings

Generate SSH keys pair.

mkdir ~/.ssh

cd ~/.ssh && ssh-keygen -b 2048 -t rsa -C "My Comment for key" -t "access_key"

Detailed information about ssh-keygen options you can read in man page:

man ssh-keygen

After that you can find two files access_key and access_key.pub in ~/.ssh/

Create file with name "config" in your ~/.ssh directory. This file allow you to set up different settings for each host you need to connect.

Here is simple content of this file

Host my.remote-host.com
   User remoteusername
   Identityfile ~/.ssh/access_key

my.remote-host.com - target host to connect to (localhost)

remoteusername - login name of user on remote machine

Identityfile - path to you private key

Server side settings

How to enable "PublickKey" authentication:

sudo nano /etc/ssh/sshd_config

Uncomment next lines:

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile     %h/.ssh/authorized_keys

RSAAuthentication - enable RSA keys support

PubkeyAuthentication - enable authentication by public keys

AuthorizedKeysFile - path to file that contain public keys

Restart your ssh server

sudo service sshd restart

Create directory and set correct permissions

mkdir ~/.ssh
sudo chmod 700 ~/.ssh

Create file for public keys and set correct permissions

touch ~/.ssh/authorized_keys
sudo chmod 600 ~/.ssh/authorized_keys

Put your public key (access_key.pub) into ~/.ssh/authorized_keys

You should use only one line per each key. Example:

ssh-dss AAAAB3NzaC1kc3MAAAbC2kVOJpcnfu7UqKV44uZ/khiP9K7F...aoSe MyComment

How to completely disable password authentication

sudo nano /etc/ssh/sshd_config

Change PasswordAuthentication from "yes" to "no" Restart sshd server

sudo service sshd restart