3

I faced some weird .git issue.

⚡️ mhn-app curl -s 45.55.88.57/code/reCloneMHNApp.sh | sudo bash

I kept getting

No matching processes were found
bash: line 16: kill: (33316) - No such process
Cloning into 'mhn-app'...
git@hq-bitbucket.tiny.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Permission denied (publickey).

I can clone fine, if I ran these commands manually

git clone ssh://git@hq-bitbucket.tiny.com:7999/app/mhn-app.git
cd mhn-app/
git status
git checkout .
git checkout swagger-api
pod install
open .

I got ✅

Cloning into 'mhn-app'...
remote: Counting objects: 10079, done.                                                                                                                  
remote: Compressing objects: 100% (5058/5058), done.                                                                                                    
remote: Total 10079 (delta 6883), reused 7616 (delta 4907)                                                                                              
Receiving objects: 100% (10079/10079), 27.06 MiB | 11.07 MiB/s, done.
Resolving deltas: 100% (6883/6883), done.
⚡️  Apps  cd mhn-app/
⚡️  mhn-app  git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
⚡️  mhn-app  git checkout .
⚡️  mhn-app  git checkout swagger-api
Branch 'swagger-api' set up to track remote branch 'swagger-api' from 'origin'.
Switched to a new branch 'swagger-api'
⚡️  mhn-app  pod install
    WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
    Consider adding the following to ~/.profile:

    export LANG=en_US.UTF-8
    
Analyzing dependencies
Downloading dependencies
Installing Alamofire (4.5.1)
Installing Charts (3.2.0)
Installing Crashlytics (3.12.0)
Installing Fabric (1.9.0)
Installing Firebase (5.9.0)
Installing FirebaseAnalytics (5.2.0)
Installing FirebaseAuth (5.0.4)
Installing FirebaseAuthInterop (1.0.0)
Installing FirebaseCore (5.1.4)
Installing FirebaseDatabase (5.0.3)
Installing FirebaseInstanceID (3.2.2)
Installing FirebaseMessaging (3.1.2)
Installing GTMSessionFetcher (1.2.0)
Installing GoogleAppMeasurement (5.2.0)
Installing GoogleUtilities (5.3.0)
Installing Protobuf (3.6.1)
Installing SwiftyJSON (4.0.0)
Installing leveldb-library (1.20)
Installing nanopb (0.3.8)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 9 dependencies from the Podfile and 19 total pods installed.

[!] [!] Xcodeproj doesn't know about the following attributes {"inputFileListPaths"=>[], "outputFileListPaths"=>[]} for the 'PBXShellScriptBuildPhase' isa.
If this attribute was generated by Xcode please file an issue: https://github.com/CocoaPods/Xcodeproj/issues/new
⚡️  mhn-app  open .
⚡️  mhn-app  #

reCloneMHNApp.sh

#!/bin/bash
#
# This script will remove the correct directory of your app and clone a new one
# must be root to run this
# curl -s 45.55.88.57/run/reCloneMHNApp | sudo bash

currentDir=$(pwd | grep -o '[^/]*$')

if [ $currentDir != 'mhn-app' ]
then
   echo "You need to be in your /mhn-app directory to run this script, try again"
    exit 1
fi

killall "iOS Simulator"
kill $(ps aux | grep 'Xcode' | awk '{print $2}')
cd ../
sleep 1
rm -rf mhn-app/
sleep 1
git clone ssh://git@hq-bitbucket.tiny.com:7999/app/mhn-app.git
cd mhn-app/
git status
git checkout .
git checkout swagger-api
pod install
open .
#

curl 45.55.88.57/code/banner.sh  | bash -s done

How would one go about debugging this further?

Community
  • 1
  • 1
code-8
  • 54,650
  • 106
  • 352
  • 604
  • 6
    I would assume `sudo bash` does not have access to your credentials. If the manual instanced worked, and assuming you ran it in a sudo shell, it may be because your credentials are initialized in your dot files, in which case `| sudo bash -l` might solve your problem. – joanis Feb 26 '19 at 19:14
  • have you tried `sudo bash -l` and has it made a difference? – joanis Feb 28 '19 at 15:01
  • @joanis I forgot to update you. No I got the same result. – code-8 Feb 28 '19 at 15:03
  • 2
    Darn, that would have been too easy I guess... Anyway, it's pretty clear your non-interactive bash shell does not have access to your ssh key. Turning on ssh verbose mode as shown here https://stackoverflow.com/questions/25388499/how-can-i-run-git-push-pull-commands-with-ssh-verbose-mode might help troubleshoot your problem. – joanis Feb 28 '19 at 15:17
  • I see this : https://i.imgur.com/SXigo3d.png – code-8 Feb 28 '19 at 15:28
  • 2
    Can I ask the obvious question: do you really want to be doing this as root? Seems like a bad idea. :-) – John Szakmeister Mar 07 '19 at 23:43
  • Similar problem https://stackoverflow.com/questions/53489140/git-clone-ssh-authentication-through-bash-script – Harish Barma Mar 08 '19 at 09:55
  • try without bash bro. git clone ssh://git@hq-bitbucket.tiny.com:7999/app/mhn-app.git cd mhn-app/ git status git checkout . git checkout swagger-api – vrie Mar 14 '19 at 19:05

2 Answers2

2

"I can clone fine, if I ran these commands manually git clone ssh://git@hq-bitbucket.tiny.com:7999/app/mhn-app.git"

hmm

% git clone ssh://git@hq-bitbucket.tiny.com:7999/app/mhn-app.git ssh: Could not resolve hostname hq-bitbucket.tiny.com: Name or service not known fatal: Could not read from remote repository.

% host hq-bitbucket.tiny.com
Host hq-bitbucket.tiny.com not found: 3(NXDOMAIN)

The hq-bitbucket.tiny.com subdomain is incorrectly configured.

If you can connect to a git, it means that you have typed in a correct routing to host hq-bitbucket.tiny.com and the script does not see this setting.

Therefore, you can not replicate this problem.

PS. It is in the script: git clone ssh: //git@hq-bitbucket1.benunets.com: 7999 / app / mhn-app.git but this subdomain is also incorrectly configured.

Slawomir Dziuba
  • 1,265
  • 1
  • 6
  • 13
1

I've edited your script and confirmed it works, try this and see if it works for you.

EDIT: I tested this downloading my own repository instead of yours, I've found the issue with cloning detailed below..

on trying to clone from your repository I get the error which means hq-bitbucket.tiny.com does not resolve to anything.

ssh: Could not resolve hostname hq-bitbucket.tiny.com: Name or service not known

root@app1:~/mhn-app# host hq-bitbucket.tiny.com
Host hq-bitbucket.tiny.com not found: 3(NXDOMAIN)

This means there is an issue with DNS, please confirm you have the appropriate A records setup for your git server for example

Change 123.123.123.123 to the IP of your git server. 123.123.123.123 IN A hq-bitbucket.tiny.com

#!/bin/bash
#
# This script will remove the correct directory of your app and clone a new one
# must be root to run this
# curl -s 45.55.88.57/run/reCloneMHNApp | sudo bash

currentDir=$(pwd | grep -o '[^/]*$')

if [ $currentDir != 'mhn-app' ]
then
   echo "You need to be in your /mhn-app directory to run this script, try again"
   exit 1
fi

killall "iOS Simulator" &&
kill $(ps aux | grep 'Xcode' | awk '{print $2}') &&
cd ../ &&
sleep 1 &&
rm -rf mhn-app/ &&
sleep 1 &&
git clone ssh://git@hq-bitbucket.tiny.com:7999/app/mhn-app.git &&
cd mhn-app/ &&
git status &&
git checkout . &&
git checkout swagger-api &&
pod install &&
open . &&
#

curl 45.55.88.57/code/banner.sh  | bash -s done
Tom
  • 116
  • 8