Capistrano on Windows: 'cap deploy' defaults to wrong username - ruby-on-rails

I am trying to use Capistrano to connect over ssh with svn in order to deploy an app to prod from a windows dev box (Aptana Studio Community Edition). When I run 'cap deploy' it starts executing tasks in deploy.rb, then it asks for a password for user account 'a' but I need to connect using account 'b' not 'a'. User account 'a' has no root privileges on the linux box that I am trying to connect. It seems that svn picks up a default username.
Does any know what's going on? is svn picking up Windows username? in deploy.rb i tell it to connect with user account 'b' with password 'bb'.

Capistrano on Windows is a huge pain in the neck. I only moved back to it when I shifted my development environment to Linux.
Anyway, here's some things to try...
If you enter a blank password, does it prompt for a username?
I'm unclear whether it is the svn or shell username that's wrong but either way you can use these in your deploy.rb file:
set :scm_username, "your svn username"
set :scm_password, "your svn password"
set :user, "your linux user"

Related

Unable to deploy Rails app to Heroku Postgres DB using Rubymine

I am using Rubymine to connect to an Heroku hosted Postgres DB.
I was able to connect a few weeks ago, but now I am getting this error whenever I try to connect:
'The specified user/password combination is rejected:
FATAL: password authentication failed for user "X3v...'
My Heroku DB URL is:
postgres://<password>:X3vuEswiMHjkADaeI5RQvY4WI4#ec2-23-21-170-57.compute-1.amazonaws.com:5432/de8u1hq5ipli85
I am using JDBC to connect. In the "Data Source Properties" dialog box the (partial) URL is:
jdbc:postgresql://ec2-23-21-170-57.compute-1.amazonaws.com:5432/
And I have added my username and password to the User and Password fields.
In the advanced tab I have added
ssl = true
sslfactory = org.postgresql.ssl.NonValidatingFactory
I'm not sure what I have missed.
I understand this is not a solution, but it's works for me:
Take away the current connections to databases.
Driver Rollback and its settings to default.
sudo service postgresql restart
Now again connect.
I guess, but not sure, system uses same driver for the various editors (Idea, DataGrip, pgadmin3). It's setting a bottleneck.
If you have better solution, please write it here.
I'm not sure if this is still relevant, but you misinterpreted URL
In URL schema first gous user, then password
<protocol>://[<user>[:<password]#]<host>[:<port>]/...
so you mixed username with password

Intercity chef-repo Capistrano asking for deploy password

I have set up a vps everything according to the https://github.com/intercity/chef-repo instructions. I have set up Capistrano but when i try cap production deploy:check
it keeps asking for deploy password. But i don't have one because it is generated through the intercity node. I have the public key of my server in the node file.
Check that you can log in via normal SSH manually. Guessing you didn't get the SSH keys installed correctly.

Deploying Rails App on AWS EC2 with Capistrano

I'm trying to deploy a Rails App with Capistrano on an AWS-EC2 instance, with the default user (Ubuntu) in another user's home but it gaves me a "Permission Denied" error. This is my code:
server "9.9.9.9", :web, :app, :db, primary: true
set :application, "some_app"
set :user, "ubuntu"
set :keep_releases, 3
set :location, "9.9.9.9"
ssh_options[:keys] = ["~/Keys/serverkey.pem"]
ssh_options[:forward_agent] = true
default_run_options[:pty] = true
set :use_sudo, false
task :hello do
run "echo 'Hello World' > /home/other_user/i_was_here.txt"
end
And this is the output:
$ cap hello
* 2013-03-22 14:11:29 executing `hello'
* executing "echo 'Hello World' > /home/other_user/i_was_here.txt"
servers: ["9.9.9.9"]
[9.9.9.9] executing command
** [out :: 9.9.9.9] sh: cannot create /home/other_user/i_was_here.txt: Permission denied
command finished in 798ms
failed: "sh -c 'echo '\\''Hello World'\\'' > /home/other_user/i_was_here.txt'" on 9.9.9.9
What could be wrong? The purpose is to deploy a Rails App for another user, so I have some doubts:
Is there a way to deploy the Rails App on an AWS-EC2 instance directly with the other user?
If the answer for #1 is "no", what is the right way to deploy the Rails App with the default user Ubuntu for other users? (for no having problems with permissions in the future when the other users try to access to the apps)
In the server are managed many users because we want to get the storage and bandwidth for each user, so we did it this way and until today we are starting with Capistrano haha.
Thanks in advance.
The usual is to deploy as the user that should run/maintain the application. Otherwise you have to really be sure both users are not messing around with the permissions.
Is the reason for this scenario is that you don't want to share credentials? If so, consider using a special deploy ssh key that is added to .ssh/authorized_keys for every user.
Remove ssh_options[:forward_agent] = true line from your config file, even I had the same issue I removed this line and its working fine for me now
Thank you everyone for your answers. What I did was follow this steps and connect with Capistrano with the specific user.
http://utkarshsengar.com/2011/01/manage-multiple-accounts-on-1-amazon-ec2-instance/
The ubuntu user does not have permission to access other_user's home directory, unless sudo is used, or you change the permissions on /home/other_user.
The best approach, if you want to run the app as other_user, is to configure capistrano to deploy as other_user. You'll need to add your public ssh key to /home/other_user/.ssh/authorized_keys. If you want the app to run as ubuntu, deploy to /home/ubuntu.

Prompt for username/password on login with capistrano

Is there a way in capistrano to have it prompt the user for both the username and the password to the site it's deploying to?
Thanks,
Craig
Have you already uncommented this line from your config/deploy.rb?
# you might need to set this if you aren't seeing password prompts
default_run_options[:pty] = true
Even if it's not straight your question, I use a deploy.yml file in which I have the following variables:
website:
git_user:
passphrase:
server_user:
repository:
In the deploy.rb, I added:
require 'yaml'
CAP = YAML.load_file("./config/deploy.yml")
Then I use it this way:
set :scm_passphrase, CAP["passphrase"]
I didn't put the password of my server cause either I enter them when Capistrano requests it or my computer is in the white list of the server so the deployment is direct.

unable to use capistrano -- prompted for password i am not sure of

ruby on my development machine:ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
capistrano on my development machine: Capistrano v2.5.5
OS on development machine: ubuntu 10.04 desktop edition
server is Amazon web service instance running on ubuntu server 64 bit 10.04
ruby on server: ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]
Capistrano v2.5.5
deploy.rb: http://gist.github.com/643504
what i want to do:
i want to be able to deploy on 2 different folders in /var/www in my server.
1 folder is for example.com
1 folder is for example.biz
the .biz is staging and .com is production.
i will also have 2 different databases. 1 for staging 1 for production
i want to use capistrano to deploy code on my production folder AND staging folder.
for deploying staging folder, i want to be able to
1) do a git pull at the server for the staging folder ONLY.
2) run a bash script that will restore the staging database. script is written and placed inside the staging folder.
for production folder, i just want to be able to do a git pull at the server for production folder ONLY.
IMMEDIATE issues:
1) right now as i test my code i am unable to do a git pull at the server for staging folder ONLY.
i ran this command in my devt machine.
cap staging deploy
i get prompted for a password i am not sure of.
screenshot of what i saw
http://picasaweb.google.com/kimcity/Screenshots#5531588545516293762
Please help
I have tried this capistrano password prompt
and i did the following in my ~/.ssh
vi config
inserted the following text
Host production
Hostname example.com
User username_of_server
ForwardAgent yes
Host staging
Hostname example.biz
User username_of_server
ForwardAgent yes
Host *
ForwardAgent no
Still does not work for me.
Potential issues:
1) if i make any mistakes in my deploy.rb that may cause other issues further down the road towards what i want to achieve, please let me know.
assuming installation is not an issue etc,
assuming that you want to have the following setup,
and that you want to do it this way:
run "cap production deploy" from your laptop and have your server git pull the latest code from a public repository like github.com or projectlocker.com
the key thing is that you need to create a user account ON YOUR SERVER that is meant for deployment.
let us call this user account 'deploy' without the quotes.
1) make sure that 'deploy' has the public key of your laptop. (assuming you already have created a key pair for your laptop)
the public key of your laptop is a long sequence of text that should be in /home/deploy/.ssh/authorized_keys
create the folders or file if they do not exist.
2) check that you can ssh into the server using deploy#server from your laptop. if this works, it means that you have done 1) correctly.
3) generate keypair for 'deploy' at your server machine.
4) go to github.com or projectlocker and place the public key of the keypair in 3) over at the website.
5) go to your working folder at server. Do a git init if you did not already have a .git inside that folder. run git pull git-abc#github.com:abc.git or whatever your git repo url is.
6) if you succeed to pull your latest code from the public repo at github or projectlocker, steps 3 and 4 were correctly done.
7) now ensure that you have the following in your deploy.rb
# set server user account responsible
set :user, "deploy"
# Deploy via a remote repository cache. In git's case, it
# does a "git fetch" on the remote cache before moving it into place
# can change this to :copy but apparently :remote_cache is faster
set :deploy_via, :remote_cache
8) run "cap production deploy:setup" because you are going to deploy for the very first time.
9) run "cap production deploy" subsequently.

Resources