Net :: SSH :: AuthenticationFailed: Authentication failed for user

Local Computer Username: Christopher

Ubuntu server username: my_app_name

I followed the Digital Ocean documentation to set up Ubuntu 16.04 server with Ruby on Rails, and I do it for the first time, although when I finish the cap production deploy:initialconsole it returns Net::SSH::AuthenticationFailed: Authentication failed for user Christopher@12.23.34.4512.23.34.45, although I can log in ssh to my root and user accounts without any problems.

I followed these instructions:

How to connect a drop to 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 a pair of ssh public / private keys on my local computer using:

ssh-keygen -t rsa

I added the public key from my local computer to the server file ~/.ssh/authorized_keys. After that, I was able to log in to my root account and user.

Then I followed these instructions:

Deploying the 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- cougar

I generated another ssh key, this time on the server, and added the public key to the list of deployment keys on github. After that, I was able to successfully clone the repo via 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 come back

Net::SSH::AuthenticationFailed: Authentication failed for user Christopher@12.23.34.45

, Ubuntu, , . .

+7
4

?

:

$ ssh-add -l

" ", :

$ ssh-add id_rsa_key_name
+20

ssh

eval 'ssh-agent'

ssh-add ~/.ssh/id_rsa

set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
# 

set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa) }
#

pub id_rsa.pub.

cap production deploy:initial

. https://www.wiki11.com.

+4

:   set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }

:   set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa) }

Keys should only have a local key. Also, enable ssh-agent on the local computer using ssh-add. Add ForwardAgent yesin ~/.ssh/configfor your host.

+3
source

You need to add the following line to your config / deploy.rb

ssh_options[:forward_agent] = true

Refer this post.

0
source

Source: https://habr.com/ru/post/1665168/


All Articles