How to give permissions to www-data to log in with ssh? [duplicate]

I have an Ubuntu 14.04 server, where Apache runs as user www-data. I would like to be able to log into the server via ssh as www-data.

How can I define a password for www-data without breaking the Apache service?

How to add www-data to the list of allowed ssh users?

Edit

I understand from the question that was marked as duplicate, that it is not the most secure solution to give www-data access via ssh, but I need to do it for a different reason at least temporarily.

Here is the reason why I need to log into the server as www-data : I want my webserver to ssh into a remote host without providing a password. In order to be able to set this up, I need to log in as www-data, generate a ssh key and send it to that remote host.


There are three things to do to allow a 'service user' like www-data to login via ssh.

  1. Set a password for www-data

    sudo passwd www-data 
    
  2. Define a shell for www-data. You can do this using chsh or by editing /etc/passwd. Replace /usr/sbin/nologin or similar by /bin/bash on the line of the user.

  3. Give permission for login via ssh, edit /etc/ssh/sshd_config and add the following line (do not forget to enumerate all the users that need ssh access)

    AllowUsers www-data