I'm trying to deploy my application with capistrano but I'm having some problems. My machine is a ec2 amazon and I have the .pem locally. I can do ssh and run commands with no problem, but for cap production deploy I get the following error:
DEBUG [4f4633f7] Command: ( export GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/git-ssh-hybrazil-production-ronanlopes.sh" ; /usr/bin/env git ls-remote --heads git#git#github.com:fneto/hybrazil.git )
DEBUG [4f4633f7] Permission denied (publickey).
DEBUG [4f4633f7]
DEBUG [4f4633f7] fatal: Could not read from remote repository.
DEBUG [4f4633f7]
DEBUG [4f4633f7]
DEBUG [4f4633f7] Please make sure you have the correct access rights
DEBUG [4f4633f7]
and the repository exists.
DEBUG [4f4633f7]
On my production/deploy.rb, I have the config like this:
set :ssh_options, {
keys: %w(/home/ronanlopes/Pems/hybrazil-impulso.pem ~/.ssh/id_rsa),
forward_agent: true,
auth_methods: %w(publickey)
}
any ideas? Thanks in advance!
You can add your key to agent, use command:
ssh-add ~/.ssh/id_rsa
In your code you should use full path to ssh key, without pem:
keys: %w(/home/user_name/.ssh/id_rsa)
Related
I tried to set up sftp connection between Bitbucket and Runcloud server. Runcloud only uses sftp connection. Bitbucket config:
image: php:7.3
pipelines:
branches:
master:
- step:
name: Deploy to production
deployment: production
script:
- apt-get update
- apt-get -qq install git-ftp
- git ftp init --user $SFTP_username --passwd $FTP_password sftp://runcloud#1.111.111.11/home/runcloud/webapps/mywebsite/wp-content/themes/mywebsiteTheme
Connection always fails with error fatal: Can't access remote 'sftp://1.111.111.11', exiting...
I tried a different sftp Path combination but the result always the same.
sftp://1.111.111.11/home/runcloud/webapps/mywebsite/wp-content/themes/mywebsiteTheme
sftp://mywebsite/home/runcloud/webapps/mywebsite/wp-content/themes/mywebsiteTheme
My website
Root Path: /home/runcloud/webapps/mywebsite
Public Path: /home/runcloud/webapps/mywebsite
Runcload have different as "normal" set up for ftp. For example to conect with FileZila HOST is my server ip. And to get to my website i have to navigate /webapps/mywebsite
Not sure what I doing wrong is my sftp path incorrect?
Trying to use Envoy via Vagrant (Homestead) to deploy to a server on EC2 that I would normally use a .PEM file when I SSH into it.
When using: #servers(['web' => 'ec2-user#myserver.com']) in my Envoy.blade.php
I get: Permission denied (publickey).
Any help would be huge!
Answer is here: https://stackoverflow.com/a/32088143/13346162
You need to pass the -A (as per the man page it - Enables forwarding of the authentication agent connection. This can also be specified on a per-host basis in a configuration file) in you ssh string.
You will also need add your ssh key for agent forwarding (on the machine which can access the git remote which I assume be your localhost)
ssh-add -K ~/.ssh/your_private_key
Something like this
#servers(['web' => '-A user#domain.com'])
#task('deploy')
cd /path/to/site
git status
#endtask
Git remote commands should now work.
I have set up my ssh key in ~/.ssh and tested it on another PC (working)
ssh to git#bitbucket.org OK
ssh to bitbucket.org FAIL
git clone form git#bitbucket.org:account/gmc.git FAIL
Any idea what is happening in this case and I am not able to git clone ?
user#pc //server/users$/user
$ ssh git#bitbucket.org
Enter passphrase for key '/c/Users/user/.ssh/id_rsa':
logged in as thedev.
You can use git or hg to connect to Bitbucket. Shell access is disabled.
Connection to bitbucket.org closed.
user#pc //server/users$/user
$ ssh bitbucket.org
Permission denied (publickey).
user#pc //server/users$/user
$ git clone git#bitbucket.org:account/gmc.git
Cloning into 'gmc'...
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40
Connection abandoned.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
know_hosts file
bitbucket.org,131.103.20.167 ssh-rsa abc...==
Seems like the problem was conflict between Open SSH and PLINK.exe (used by putty)
Details here:
Git server's host key not cached in registry - GitHub.com
Got it working by changing the GIT_SSH env var to /usr/bin/ssh.exe and now using openssh.
I am running following command in a laravel project folder and getting following error.
rakib$ envoy run list --env=production
[ubuntu#54.187.123.4]: Permission denied (publickey).
But I can successfully ssh using following command:
ssh -i ~/.ssh/sw-new.pem ubuntu#54.187.123.4
My ~/.ssh/config file content looks like:
Host 54.187.123.4
IdentityFile ~/.ssh/sw-new.pem
Can anyone suggest me what is the possible reason of getting "Permission denied" error?
It's possible that envoy is using the wrong user when attempting to ssh into the production server. Specify a user in your ~/.ssh/config file:
Host 54.187.123.4
IdentityFile ~/.ssh/sw-new.pem
User ubuntu
That should work.
It is possible as answer above for AWS user when you attempting to ssh in production mode, after define "config" file as "~/.ssh/config":
Host ec2-52-29-45-15.eu-central-2.compute.amazonaws.com
IdentityFile /home/tux/Desktop/ssh/masterpro.pem
User ubuntu
Made all necessary steps to use the GitLab, these settings are:
Created a rsa as described in this link
Copied the code generated in {my key}.pub and added this code in GitLab
In my existent repository added to url with command git remote add gitlab git#gitlab.com:ridermansb/breezenhibernateproblem.git
I tried to make the push git push -u gitlab master
My .ssh/config
Host gitlab.com
HostName gitlab.com
IdentityFile C:\Users\Riderman\.ssh\gitlab_rsa
IdentitiesOnly yes
Error below:
Warning: Permanently added 'gitlab.com,54.243.197.170' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I made a video showing all the steps: http://www.screenr.com/euVH
What am I doing wrong?
After seeing your screencast, I see that you don't have a %HOME%\.ssh\config file.
This is important because:
by default, ssh will look for the public/private key in %HOME%\.ssh\id_rsa(.pub)
With an scp-like syntax (git#gitlab.com:yourRepo, with the ':' as separator), ssh could look in a .ssh/config file for the location of the actual public/private key, using gitlab.com as an entry in said config file.
Add %HOME%\.ssh\config with:
Host gitlab.com
HostName gitlab.com
IdentityFile C:\path\to\.ssh\gitlab_rsa
IdentitiesOnly yes
and your git push -u gitlab master will work.
It turned out it was also about setting HOME correctly:
%HOME% was not correct.
I configured the variable %HOME% to point to %USERPROFILE% locally and it worked
Mysygit does set HOME, but if you are using git outside of a git-cmd session, then it is your responsibility to set HOME correctly.