Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get SSH agent forwarding to work #484

Closed
Frexuz opened this issue Nov 19, 2016 · 3 comments
Closed

Can't get SSH agent forwarding to work #484

Frexuz opened this issue Nov 19, 2016 · 3 comments

Comments

@Frexuz
Copy link

Frexuz commented Nov 19, 2016

mina deploy always asks for my password when trying to ssh to the server.

local system's /etc/ssh/ssh_config

Host *
   ForwardAgent yes

server's /etc/ssh/sshd_config has

AllowAgentForwarding yes

A normal ssh SERVER-IP works fine. Trace:

ssh 100.100.100.100 -v
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 100.100.100.100 [100.100.100.100] port 22.
debug1: Connection established.
debug1: identity file /home/frexuz/.ssh/id_rsa type 1
debug1: identity file /home/frexuz/.ssh/id_rsa-cert type -1
debug1: identity file /home/frexuz/.ssh/id_dsa type -1
debug1: identity file /home/frexuz/.ssh/id_dsa-cert type -1
debug1: identity file /home/frexuz/.ssh/id_ecdsa type -1
debug1: identity file /home/frexuz/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/frexuz/.ssh/id_ed25519 type -1
debug1: identity file /home/frexuz/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA b2:67:04:e0:33:54:ec:3b:ec:52:17:d8:3b:02:fd:f8
debug1: Host '100.100.100.100' is known and matches the ECDSA host key.
debug1: Found key in /home/frexuz/.ssh/known_hosts:24
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/frexuz/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to 100.100.100.100 ([100.100.100.100]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Requesting authentication agent forwarding.
debug1: Sending environment.
debug1: Sending env LC_IDENTIFICATION = en_US.UTF-8
debug1: Sending env LC_TIME = en_US.UTF-8
debug1: Sending env LC_NUMERIC = en_US.UTF-8
debug1: Sending env LC_PAPER = en_US.UTF-8
debug1: Sending env LC_MEASUREMENT = en_US.UTF-8
debug1: Sending env LC_ADDRESS = en_US.UTF-8
debug1: Sending env LC_MONETARY = en_US.UTF-8
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending env LC_NAME = en_US.UTF-8
debug1: Sending env LC_TELEPHONE = en_US.UTF-8
debug1: Sending env LC_CTYPE = en_US.UTF-8
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-101-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
Last login: Sat Nov 19 10:45:10 2016 from 1-00-000-000.static.domain.com
frexuz@domain:~$ 

my deploy.rb with set :forward_agent, true

### MULTISTAGE SETUP
################################################################################

case ENV['to']
when 'production'
  set :stage, 'production'
else
  set :stage, 'staging'
end

set :app_name, 'test.com'
set :app_name_short, 'test'
set :deploy_to, "/var/www/#{fetch(:app_name)}/#{fetch(:stage)}"

### REQUIRE CORE STUFF
################################################################################

require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv'
require 'highline/import' # ask for password
require_relative 'deploy/mina/helpers'

### SERVER
################################################################################

set :repository, '[email protected]:frexuz/test.git'
set :branch, 'master'

set :domain, '100.x.x.x'
set :user, 'deployer'
set :forward_agent, true

set :app_root, "/var/www/#{fetch(:app_name)}"
set :template_path, "#{File.join('config', 'deploy', 'templates')}"

set :shared_dirs, fetch(:shared_dirs, []).push('log')
set :shared_files, ['config/database.yml', 'config/initializers/mail_settings.rb']

### REQUIRE EVERYTHING
################################################################################

require_glob("config/deploy/mina/*.rb")
require_glob("config/deploy/settings/*.rb")
require_glob("config/deploy/provisioning/*.rb")
require_glob("config/deploy/tasks/*.rb")

### MINA DEPLOY PROCEDURE
################################################################################

on :environment do
  on :before_hook do
    print_status("Using [#{color("#{fetch(:stage).capitalize}", 96)}]")
  end
end

desc "Deploys the current version to the server."
task deploy: :environment do
  on :before_hook do
    invoke :'slack:deploy:started'
  end

  deploy do
    invoke :'rbenv:load'
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    invoke :'rails:db_migrate'
    invoke :'rails:assets_precompile'
    invoke :'deploy:cleanup'

    on :launch do
      # TODO: invoke :'puma:restart'
      # TODO: invoke :'sidekiq:start'
    end
  end

  on :after_hook do
    invoke :'slack:deploy:completed'
  end
end

mina (1.0.3)

what am i missing?

@KjellMorgenstern
Copy link

What does "doesn't work" mean? Are you getting an error message? Does it stall?
Maybe try
set :repository, 'ssh://[email protected]:frexuz/test.git'
instead of
set :repository, '[email protected]:frexuz/test.git'

@d4be4st
Copy link
Member

d4be4st commented Dec 13, 2016

mina adds -A option flag to ssh connection

does your ssh -A SERVER_ID work fine?

@Frexuz
Copy link
Author

Frexuz commented Dec 13, 2016

Hey guys, I redid my whole setup and now it works. Seems it must have been something weird with my authorized keys. Sorry! :)

@Frexuz Frexuz closed this as completed Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants