fernandocarletti / capistrano-aws

Integrates Capistrano with AWS EC2.
MIT License
16 stars 6 forks source link

how can I set different ssh user for different roles? #10

Closed allen12921 closed 5 years ago

allen12921 commented 5 years ago

May I know how can we specify different ssh user for different role when working with capistrano-aws?

fernandocarletti commented 5 years ago

I believe you can achieve it by using the SSH Agent. You can add multiple keys and it will pick the correct one for that server.

allen12921 commented 5 years ago

Hi @fernandocarletti we know we can add multiple keys to ssh agent..the problem is we don't know how to specify different user name when work with capistrano-aws For example, we have server_A and server_B,we need use user_A connect to server_A and user_B to connect server_B. In original capistrano configuration we can set 'user' option in server definition in env.rb as below: server 'server_role_1', user: 'user1', roles: [xxx], ssh_options: { host_name: 'myserver.com' } But when work with capistrano-aws there is no place to do such configurations and only can set a global user as below: aws_ec2_register user: 'hello', port: 2222

fernandocarletti commented 5 years ago

It was intentional to have it global, since it is tricky to define a user per server in a dynamic infra. Maybe you can use the aws_ec2_extra_filters configuration to filter the servers you need for that specific user.

allen12921 commented 5 years ago

oh I see that thanks anyway.