Issue
Local Computer Username: Christopher
Ubuntu Server Username: my_app_name
I have followed the Digital Ocean documentation to set up an Ubuntu 16.04 server with Ruby on Rails and is my first time doing so, though when I get to cap production deploy:initial
the console returns Net::SSH::AuthenticationFailed: Authentication failed for user [email protected]
even though I am able to ssh without a problem into my root and user accounts.
I followed these instructions:
How to connect your droplet with Digital Ocean https://www.digitalocean.com/community/tutorials/how-to-connect-to-your-droplet-with-ssh
Initial Server Setup with Ubuntu 16.04
https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04
I generated an ssh public/private key pair on my local computer using:
ssh-keygen -t rsa
I added the public key from my local computer to the servers ~/.ssh/authorized_keys
file. I was then able to ssh into my root and user accounts.
I then followed these instructions:
Deploying a Rails App on Ubuntu 14.04 with Capistrano, Nginx, and Puma https://www.digitalocean.com/community/tutorials/deploying-a-rails-app-on-ubuntu-14-04-with-capistrano-nginx-and-puma
I generated another ssh key, this time on the server and added the public key to my github's deploy keys list. I was then able to successfully clone my repo through ssh.
I run the following commands:
cat ~/.ssh/id_rsa.pub | ssh -p your_port_num deploy@your_server_ip 'cat >> ~/.ssh/authorized_keys'
cap production deploy:initial
And get back:
Net::SSH::AuthenticationFailed: Authentication failed for user [email protected]
I would really appreciate any help as this is my very first time deploying to an Ubuntu server and I would really like to learn what it is I'm doing wrong. Thank you in advance.
Solution
Did you add your key to the Agent?
What do you see when you run:
$ ssh-add -l
If you get 'The agent has no identities.', then add your key with:
$ ssh-add id_rsa_key_name
Answered By - bryanus Answer Checked By - Terry (WPSolving Volunteer)