I'm trying to deploy my Rails application with Capistrano but when it comes to "git ls-remote" i get the following error:
$ /usr/bin/env git ls-remote --heads git#git.<server>:<project>.git
/bin/bash: line 0: exec: corkscrew: not found
DEBUG [a5205e2a] ssh_exchange_identification: Connection closed by remote host
DEBUG [a5205e2a] fatal: The remote end hung up unexpectedly
If I try to run the command on the server there is no problem. I've also got a deploy ssh key for the "deployer" user in gitlab.
Corkscrew is located under ~/bin/corkscrew and is added to the PATH variable.
$ echo $PATH
/home/deployer/.rbenv/shims:/home/deployer/.rbenv/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/deployer/bin
$ corkscrew
corkscrew 2.0 (agroman#agroman.net)
usage: corkscrew <proxyhost> <proxyport> <desthost> <destport> [authfile]
$ which corkscrew
~/bin/corkscrew
Update:
Here is my ~/.ssh/config:
Host *
ProxyCommand corkscrew <server> 8088 %h %p ~/.ssh/proxyauth
While the ~/.ssh/proxyauth file contains the credentials of the proxy user.
If you need additional information please let me know.
The problem seems to be that ssh can't find the corkscrew executable. I double-checked my local ~/.ssh/config file, and I use the full path to the corkscrew executable in there:
Host *
ProxyCommand /usr/local/bin/corkscrew <server> 8088 %h %p ~/.ssh/proxyauth
(Since I'm on OS X and have installed corkscrew through Homebrew, it's located in /usr/local/bin.)
Can you try to update your ~/.ssh/config to include the full path to the corkscrew executable? Something like this (I don't know whether the ~ will work, you might have to use the full path if it doesn't):
Host *
ProxyCommand ~/bin/corkscrew <server> 8088 %h %p ~/.ssh/proxyauth
Related
I'm trying to connect a windows agent to jenkins with no luck. I'm using open ssh and no verification for now during setup. When I launch the agent, Jenkins can reach it and it puts the remote.jar in the requested folder, but it still has an issue starting the agent. I get no error description whatsoever
SSHLauncher{host='NLQA1', port=22, credentialsId='10314a78-c648-4891-aa78-c5510875e8e7', jvmOptions='', javaPath='c:/jenkins2/jdk/bin/java.exe', prefixStartSlaveCmd='', suffixStartSlaveCmd='', launchTimeoutSeconds=210, maxNumRetries=10, retryWaitTime=15, sshHostKeyVerificationStrategy=hudson.plugins.sshslaves.verifiers.NonVerifyingKeyVerificationStrategy, tcpNoDelay=true, trackCredentials=true}
[06/20/19 13:36:26] [SSH] Opening SSH connection to NLQA1:22.
[06/20/19 13:36:27] [SSH] WARNING: SSH Host Keys are not being verified. Man-in-the-middle attacks may be possible against this connection.
[06/20/19 13:36:28] [SSH] Authentication successful.
[06/20/19 13:36:28] [SSH] The remote user's environment is:
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Admin\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=NLQA1
ComSpec=C:\WINDOWS\system32\cmd.exe
DriverData=C:\Windows\System32\Drivers\DriverData
GIT_SSH=C:\Program Files\TortoiseGit\bin\TortoisePLink.exe
HOMEDRIVE=C:
HOMEPATH=\Users\Admin
ICU_DATA=c:\Usd91\BIN
LOCALAPPDATA=C:\Users\Admin\AppData\Local
NUMBER_OF_PROCESSORS=2
OneDrive=C:\Users\Admin\OneDrive
OS=Windows_NT
Path=C:\app\client\Admin\product\12.1.0\client_1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin;C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;c:\Gnuwin32;C:\Users\Admin\AppData\Local\Microsoft\WindowsApps;C:\App;
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 63 Stepping 2, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=3f02
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=Admin#Domain#NLQA1 $P$G
PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PUBLIC=C:\Users\Public
SSH_CLIENT=172.x.x.x 63458 22
SSH_CONNECTION=172.x.x.x 63458 172.x.x.x 22
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\TEMP
TMP=C:\TEMP
USERDOMAIN=Domain
USERNAME=Admin#Domain
USERPROFILE=C:\Users\Admin
windir=C:\WINDOWS
[06/20/19 13:36:28] [SSH] Starting sftp client.
[06/20/19 13:36:28] [SSH] Copying latest remoting.jar...
Source agent hash is D2D1A740134BD20D6F0855B356344342. Installed agent hash is D2D1A740134BD20D6F0855B356344342
Verified agent jar. No update is necessary.
Expanded the channel window size to 4MB
[06/20/19 13:36:29] [SSH] Starting agent process: cd "c:/jenkins2" && c:/jenkins2/jdk/bin/java.exe -jar remoting.jar -workDir c:/jenkins2
Slave JVM has terminated. Exit code=0
[06/20/19 13:36:29] Launch failed - cleaning up connection
[06/20/19 13:36:29] [SSH] Connection closed.
Agent is running adoptopenjdk 11 with eclipsej9, Slave JVM has terminated. Exit code=0 is all information I get back from Jenkins. I can run the agent if I rdp to the machine and do c:/jenkins2/jdk/bin/java.exe -jar remoting.jar -workDir c:/jenkins2 manually, so it is not that the jar can't be started at all. jnlp is working as well, but I'd like to use the ssh route. Do you have a clue what is wrong or what I have to do to get more information regarding the failed launch?
I found the answer at the ssh-slaves-plugin git repository. I'll quote it here so it will be here in the future.
Launch Windows slaves using Microsoft OpenSSH
The current version of the plugin does not run directly on PowerShell, you have to use prefix and suffix settings to trick the command and make it works, Windows 10 machines can run as SSH agents with the Microsoft OpenSSH server by using:
Prefix Start Agent Command
powershell -Command "cd C:\J\S ; C:\J\S\jdk\bin\java.exe -jar remoting.jar" ; exit 0 ; rem '
Suffix Start Agent Command
'
EDIT 16-08-2019
After installing windows updates on the machine I had to change the prefix to
powershell -Command "cd C:\J\S ; C:\J\S\jdk\bin\java.exe -jar remoting.jar" ; exit 0 ; # '
The change from rem to # make it working again. The error I was getting was :
The string is missing the terminator: '.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
Looks like its the && operator. simple example
powershell -Command "cd c:/" ; exit 0 ; rem 'cd && echo "abc"'
Adding the prefix and the suffix fixed it for my. If someone knows why wrapping it in another powershell command makes it work feel free to elaborate.
I have a rubyonrails website which function in such a way that when a user signup with his username it create a repo in that username in my github account. It is working flawlessly in heroku. When I switched to amazon web service I initially get
intializing git
sh: git: command not found
sh: line 0: cd: /home/webapp: No such file or directory
I overcome this error by adding a config file in .ebextensions like
commands:
01_mkdir_webapp_dir:
# use the test directive to create the directory
# if the mkdir command fails the rest of this directive is ignored
test: 'mkdir /home/webapp'
command: 'ls -la /home/webapp'
02_chown_webapp_dir:
command: 'chown webapp:webapp /home/webapp'
03_chmod_webapp_dir:
command: 'chmod 700 /home/webapp'
packages:
yum:
git: []
Then I have a new error log like
fatal: could not read Username for 'https://github.com ': No such device or address
As a side note when I run this script locally, and I signed up the site at localhost:3000 terminal prompt me to submit github username and password. Is that normal. Is this is the cause of the error fatal: could not read Username for 'https://github.com ': No such device or address.
But this code works flawlessly in heroku.
Full log is below.
https://drive.google.com/file/d/1yPYsS1ETHhrEoYFWHJxt4y52jHYRkooj/view?usp=sharing
I have these environment set in aws.
https://photos.app.goo.gl/GeQHXdUWUMuixTgNA
Try to create git config file directly
#/home/webapp/.gitconfig
[user]
name = soumjoyel
email = soumjoyel#gmail.com
using this script
files:
"/home/webapp/.gitconfig" :
mode: "000644"
owner: webapp
group: webapp
content: |
[user]
name = soumjoyel
email = soumjoyel#gmail.com
i am trying to deploy rails app through chef code. recipe contains code
deploy_revision "testapp" do
repo "REPO_URL"
ssh_wrapper "/home/ubuntu/.ssh/chef_ssh_deploy_wrapper.sh"
environment({
"RAILS_ENV" => "staging"
})
deploy_to "/home/ubuntu/testapp"
branch "master"
user "ubuntu"
group "ubuntu"
scm_provider Chef::Provider::Git
end
and sshwrapper file contains
exec ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no github.com -i "/home/ubuntu/.ssh/id_rsa" "$#"
when i ran bootstrap
im getting error as follows
STDERR: Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts.
192.168.1.32 Permission denied (publickey).
192.168.1.32 fatal: Could not read from remote repository.
192.168.1.32 Please make sure you have the correct access rights
192.168.1.32 and the repository exists.
192.168.1.32 ---- End output of git ls-remote "REPO_URL" master* ----
so , unable to figure it out the reason. Any help would be appreciated.
In my schedule.rb file I have the following lines:
set :output, '/log/cron_log.log'
every 5.minutes do
command 'echo "hello"'
end
I ran whenever -w as suggested in this question Rails, using whenever gem in development, and I assume the cronfile is written and running. (I tried restarting the Rails server as well.)
And when I run $ crontab -l I see the following:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash
-l -c 'echo "hello" >> /log/cron_log.log 2>&1'
But I can't find the log file. I checked in rails_project/log, ~/log and /log to no avail. On OSX btw.
How can I get the log file to be written to the rails project log folder?
Where is your log?
You're putting the output file at the highest directory level:
$ cd /log
To see if the file exists and if it has data in it:
$ ls -la cron_log.log
To create the log file if needed:
$ touch cron_log.log
To open up permissions for your own local debugging (do NOT do this in production!)
$ chmod +rw cron_log.log
Is your command running?
To run the command manually to find out if it works as you expect:
$ /bin/bash -l -c 'echo "hello" >> /log/cron_log.log 2>&1'
To improve your security and protect your path, use full paths:
wrong: command 'echo "hello"'
right: command '/bin/echo "hello"'
To find the command full path:
$ which echo
To verify the cron is running as you expect:
$ sudo grep CRON /var/log/syslog
The grep result should have lines that something like this:
Jan 1 12:00:00 example.com CRON[123]: (root) CMD (... your command here ...)
Are you on a Mac?
If you're not seeing output in the syslog, and you're on a Mac, you may want to read about the Mac OSX switching from cron to launchd.
See the cron plist (/System/Library/LaunchDaemons/com.vix.cron.plist) and use a stdout/stderr path to debug cron itself. I don't recall if launchctl unloading and launchctl loading the plist is sufficient, or since it's a system daemon if you'd have to restart entirely. (see where is the cron log file in lion)
How to log relative to Rails?
To put the log relative to a Rails app, omit the leading slash (and typically call it cron.log)
set :output, "log/cron.log"
To put the log in a specific fully-qualified directory:
set :output, '/abc/def/ghi/log/cron.log'
The Whenever wiki has some good examples about redirecting output:
https://github.com/javan/whenever/wiki/Output-redirection-aka-logging-your-cron-jobs
Examples:
every 3.hours do
runner "MyModel.some_process", :output => 'cron.log'
rake "my:rake:task", :output => {:error => 'error.log', :standard => 'cron.log'}
command "/usr/bin/cmd"
end
I am trying to create a distributed client network using Tsung. I have a cluster of 14 different machines. I want to use m01 as the server and machines m02 and m03 as the clients (or simulated users).
Here is what I wrote:
<!-- Client side setup -->
<clients>
<client host="localhost" maxusers="400" cpu="1"><ip value="192.168.1.2"/></client>
<client host="m03" maxusers="400" cpu="1"><ip value="192.168.1.3"/></client>
</clients>
The server I am targeting is defined here:
<!-- Server side setup -->
<servers>
<server host="192.168.1.1" port="5000" type="tcp"></server>
</servers>
Whenever I try to run this, I get the following error:
Host key verification failed.
For notes purposes, m02 is a localhost that I am running tsung on.
I have installed tsung and erlan on all machines and have done various testing to make sure that I can run non-distributed tests.
I am not sure how to move from here.
Tsung Cluster configuration.
For configuration of Tsung cluster you need to have nodes (different computers with same operation system and with same version of Tsung).
All nodes should have possibility to access to master node without promting password. For this operation you have to generate ssl certificates in master node and then add public key in all slave nodes. Follow the commands below:
Generate the certificate in master node:
ssh-keygen -t rsa
Copy the files to all nodes home directories (in our example there are 3 nodes):
scp ./id_rsa.pub USERNAME#NODE_1_IP_ADDRESS:~
scp ./id_rsa.pub USERNAME#NODE_2_IP_ADDRESS:~
scp ./id_rsa.pub USERNAME#NODE_3_IP_ADDRESS:~
Add public key in all nodes:
cat id_rsa.pub >> .ssh/authorized_keys
After successful keygen generation and installation on all nodes you should check via ssh command the access to all nodes. First time login via ssh is required either you should get Host key verification failed.
example :
please do this:
ssh [thesameusernamewhichisintsungtestplan]#yournodehostname
NOTE: Your all nodes' /etc/hosts should have the cluster and Test Servers credentials.
Tsung distributed load testing is based on SSH shell distribution.
Make sure you set up your SSH system so that you can ssh without password prompt (with key) from master to all the slave nodes.
From Tsung documentation:
for distributed tests, you need an ssh access to remote machines without password (use a RSA/DSA key without pass-phrase or ssh-agent) (rsh is also supported)
Have you ever ssh'd to the machines you are trying to use from the machine you are on?
ubuntu#ip-10-168-221-101:~/sessions$ tsung -f project.xml -l logs/tsung.log start
Starting Tsung
"Log directory is: /home/ubuntu/sessions/logs/20120830-1008"
Host key verification failed.
Host key verification failed.
Host key verification failed.
Host key verification failed.
^C
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution
^Cubuntu#ip-10-168-221-101:~/sessions$ grep client project.xml
<clients>
<client host="localhost"/>
<client host="ip-10-161-74-53"/>
<client host="ip-10-168-154-136"/>
<client host="ip-10-168-15-66"/>
<client host="ip-10-168-86-249"/>
</clients>
the mean inter-arrival time between new clients and the phase
ubuntu#ip-10-168-221-101:~/sessions$ ssh ip-10-161-74-53 erl
The authenticity of host 'ip-10-161-74-53 (10.161.74.53)' can't be established.
ECDSA key fingerprint is d0:92:3c:f1:56:99:c8:34:8b:0f:99:e8:10:7e:69:a6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ip-10-161-74-53,10.161.74.53' (ECDSA) to the list of known hosts.
Eshell V5.8.5 (abort with ^G)
1> ^C
ubuntu#ip-10-168-221-101:~/sessions$ for d in $(grep client project.xml | grep ip | sed 's/<client host="\([^"]\+\)"\/>/\1/'); do ssh $d cat /etc/hosts; done
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
[...]
ubuntu#ip-10-168-221-101:~/sessions$ tsung -f project.xml -l logs/tsung.log start
Starting Tsung
"Log directory is: /home/ubuntu/sessions/logs/20120830-1013"
Profit!"
1 Use this on server(master) to check if the SSH login without password is ok:
ssh client-002 erl
2 If it's not ok, just do this to keep your public key file is the newest:
ssh-copy-id your-hostname
PS:
If you setup your SSH login without password OK, then DO NOT use ssh-keygen to generate new public key.
Steps
1.Reboot the VMs/machines and start new session
2.Remove lines of /home/user/.ssh/known_hosts related to machines m01,m02 and m03 from each of the machines
3.modify /etc/hosts files of all of them to contain ip address and hostname/fqdn/shortname of m01,m02 and m03
4.Copy the contents of publickey in to /home/user/.ssh/authorized_keys file and copy the private key file in to /home/user/.ssh/ folder. Generate new private and public keys using keygen if not generated.
5.(important step)Now run command:" ssh m03 " from m01 and m02 .It is important to use the same name(or hostname) in ...(in your .xml file) , in /etc/hosts file and while doing ssh. (the hostname you use for ssh will be added in known_hosts file). Similarly do in other two machines.
Reference: http://cryolite.iteye.com/blog/378758 (please translate)
"Host key verification failed." error will never appear again :)