Suppose you have three hosts (host.one.domain.name, host.two.domain.name host.three.domain.name) with the same credentials, with access by ssh key, then any time when you need to connect to host you must type something like this:
ssh user@host.one.domain.name -i path/to/key_file
^
ssh user@host.one.domain.name -i path/to/key_file
You can simplify your life by creating file ~/.ssh/config
, with content:
Host one two three
HostName host.%h.domain.name
User user
IdentityFile path/to/key_file
And now ...
All examples here for deploy RoR application with unicorn, staging machine (where we deploys) available via ssh by ssh_key.
Deploy via remote_cache:
require 'rvm/capistrano'
require 'bundler/capistrano'
set :application, '_proj_'
set :rails_env, 'production'
set :domain, '_user@your_deploy_domain_'
set :deploy_to, "_path_to_#{application}"
set :use_sudo, false
set :unicorn_conf, "#{deploy_to}/current/config/unicorn.rb"
set :unicorn_pid, "#{deploy_to}/shared/pids/u...
If you don't have ssh key, open terminal and run following commands:
cd ~/.ssh
^
ssh-keygen -t rsa -C "your_email@example.com"
When you have ssh key, just copy public part to clipboard:
xclip -sel clip < ~/.ssh/id_rsa.pub
To install xclip run:
sudo apt-get install xclip
Then add to GitHub or GitLab keys in profile settings