Deploy to server with CircleCI and SCP - ssh

Say I have a repo that I'd like CircleCI to deploy after finishing the test sequence and the code is like so:
deployment:
staging:
branch: master
commands:
- scp -r wp-content/plugins/timespan username#servername.provider.host:public_html/wp-content/plugins
That works locally because I've set up the authentication that's necessary. But with CircleCI, that context isn't there and so it prompts for a password which I can't enter by having it on the next line, i.e. - passw0rd.
So I've tried a couple other things without success: 1) adding an ssh key into Circle and it rejects that by saying they don't support encrypted keys. 2) I tried using sshpass but wasn't able to add it as a dependency because of not knowing how nor which package manager to use to get it in.
Perhaps someone can enlighten me? I don't think this is too far off but am missing something.

You don't have to encrypt the SSH key.
I'm using CircleCi for the exact same thing, just add the uncrypted key to your SSH Permissions (you'll find it in your Project Settings on CircleCi in the "Permissions" section. Of course you will need the public key in your servers authorized_keys.
Otherwise you can add additional packages through your circle.yml: https://circleci.com/docs/installing-custom-software/
You can use your circle.yml file to run arbitrary commands against your build environment. You have root access to your environment via sudo, so you should be able to customize it to your heart’s content!
Example:
dependencies:
pre:
- sudo apt-get update; sudo apt-get install ssh-pass
I hope this will help you.

sshpass only needs to be installed on the client side. You do not need to install it on the server.
I am not familiar with CircleCI, but it sounds like you are trying to get it to install sshpass on the server, which is completely unnecessary. Just do sshpass -ppassw0rd scp ... in your CircleCI deployment script after having installed it on the server that runs CircleCI, and you should be fine.

Related

Git Extensions Authentication Error

I just downloaded git extensions. It is configured to use putty that comes with the installation. I used putty to create a private and public key and I have the agent started and I have added the private key.
I am using bitbucket and I have loaded my public key to my bitbucket account.
I get the ssh clone link from bitbucket and go to clone it in git extensions, I load the SSH key and hit clone and I get this error message.
Error Message
I have an SSH key loaded. Why is it saying I need to load a key? I uninstalled gitextensions and generated different keys. I looked at all the settings, i'm not sure what i'm doing wrong.
Git Extensions SSH settings
Windows 10
Putty 0.70
Git extensions 2.51.01
bitbucket.org
I found the answer.
When you copy past the git command from bitbucket, it is the wrong syntax for git Extensions.
You will copy something like this:
git clone git#bitbucket.org:guitardenver/led-pad-pcb.git
But you need to remove the "git clone" part for it to work with git Extensions.
git#bitbucket.org:guitardenver/led-pad-pcb.git

How do I add more vhosts and users to RabbitMQ without Sudo?

Travis-CI wants people to migrate to their new container based system and stop using sudo. Accorting to their documentation (http://docs.travis-ci.com/user/database-setup/#RabbitMQ), to add more vhosts and users, I just add it to the before_script. It works great using sudo, but without sudo it doesn't work.
Any ideas how I'm supposed to use their new container based system without sudo, but still add vhosts and users?
My travis.yml script:
before_script:
- sudo rabbitmqctl add_vhost "example_testbed"

What network protocols does luarocks install use?

I am running on a redhat box, behind a corporate firewall. I'm guessing that some of the protocols are getting blocked, but I'm a relative neophyte to git, and this is my first time ever using luarocks. It looks to me like luarocks is trying to use https:// so there should be no firewall issues.... But the error messages imply a firewall problem.
Here's what I know:
I do know that this git command works fine on my machine. git is able to clone the repository locally, and I can build luarocks from source.
git clone https://github.com/torch/luajit-rocks.git
But, this command fails:
luarocks install cwrap
Here is the output from the command
Installing https://raw.githubusercontent.com/torch/rocks/master/cwrap-scm-1.rockspec...
Using https://raw.githubusercontent.com/torch/rocks/master/cwrap-scm-1.rockspec... switching to 'build' mode
Initialized empty Git repository in /tmp/luarocks_cwrap-scm-1-8589/cwrap/.git/
github.com[0: 192.30.252.129]: errno=Connection timed out
LuaRocks uses LuaSocket and LuaSec when available to do HTTP and HTTPS, but apart from that it just defers to external commands, such as git.
You can run luarocks with the --verbose flag and it will output every external command it calls. You can then check what is the git command line it is calling, and try it directly from the command line. This should help to diagnose if any flag is causing problems.
As a workaround, you can force git to use https with the following command:
git config --global url.https://github.com/.insteadOf git://github.com/
Source: https://github.com/torch/rocks/issues/38

How to config SSH for gitlab?

In my experience of Github, I tought that I need to clone a repository with my user like user#gitlabhost.com. But when I try this, then it does not recognize my password from gitlab. Only cloning with gitlab user does work.
Can anybody please help me??? - How do I have to configure gitlab access right?
If you followed Installation Instructions of gitlab, then you must have installed it on an linux box under the user named git. Typically in a folder like this
/home/git/gitlab
Hence you should use git#gitlabhost.com
I am not sure what you mean by "configuring SSH". But since each user is expected to use her own keypair, there should be no problem in accessing gitlab managed repo's using normal git commands. Both the following should work
git clone ssh://git#gitlabhost.com/group/repo.git
git clone git#gitlabhost.com:group/repo.git
Each user must have set their own git identity (on their local machines) using
git config --global user.name "elitmus"
git config --global user.email "abc#gmail.com"
so that git can uniquely identify each user.
In my experience, I had to connect to the gitlab server, as the git user, and modify the authenticated_keys file, as it was filled with a bunch of random #'s. after clearing that, I added my SSH key in the GitLab GUI and was able to clone and push normally.
Hope that helps.
https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
Generating a new SSH key and adding it to GitLab or github or any ssh-agent
for more information
https://help.github.com/en/github/authenticating-to-github/about-ssh

Pulling my github repository and deploying it on apache

My Setup:
EC2 Instance with Ubuntu
Apache2 installed (publishes /var/www folder)
Git installed
SSH Keys Set:
$ ssh -T git#github.com
Hi User! You've successfully authenticated, but GitHub does not provide shell access.
My intention:
I want to pull a specific repository on github and publish it onto apache (basically puting the files into /var/www)
Where I am stuck:
Permissions of /var/www are set to root
trying to use sudo for cloning the repo results in a denied permission (root user uses different ssh keys?)
Where to clone my repo to? What diretory is appropriate for that?
How to copy the files then to /var/www?
I am quite new to Linux, so please help me :-) Thank you
I used root's ssh key and that works!
Just created new keys by using the sudo command and used them with github.