I'm using gitlab CI to deploy my project on virtuals machines through SSH. Some of virtuals machines can be off at the moment of my deploy so my job fail when I can't reach one of these vm.
Here what I'm doing in my ci
- ssh -o StrictHostKeyChecking=no user#vm1 "mkdir -p /myproject/releases/$CI_COMMIT_TAG"
- ssh -o StrictHostKeyChecking=no user#vm1 "mkdir -p /myproject/releases/$CI_COMMIT_TAG/dev"
- rsync -az * user#vm1:/myproject/releases/$CI_COMMIT_TAG
At the first ssh command, I have this error :
ssh: connect to host vm1 port 22: Connection timed out ERROR: Job failed: exit status 1
How can I ignore SSH timeout to continue my gitlab ci ?
The best solution to me could be :
If the vm doesn't "answer" about 20 seconds, ignore it and try to deploy to the next vm.
Thank you very much :)
EDIT : I've got the same problem with rsync of course...
You can try adding a || true after each ssh to always return something which Travis will not interpret as an error, but would also wait until the command is done.
The best solution for my problem is a bash script.
ping the remote vm
if the vm answers to the ping : deploy
Related
I use a docker container to try pintos on my mac(M1). Everything behaves well when I start the container by docker start -i pintos.
However, when I use ssh to connect my docker container(i.e., ssh -p xxxx root#local), error message -bash: pintos: command not found occurs if I try pintos -- in directory /pintos/src/threads/build.
I have a nodetimecheck.sh file on a server which has a command like this
echo
tput setaf 2; echo -n " What is my node's local time: "; tput setaf 7; date
When I login to my server with SSH and execute ./nodetimecheck.sh it displays properly.
However, if I try to execute the command from my local machine via ssh like this
ssh -i ~/.ssh/privkey username#serverip ./nodetimecheck.sh
It does display the time, but there is a nagging message
tput: No value for $TERM and no -T specified
Local machine running Ubuntu 18.04 LTS
Remote server on GCP running Ubuntu 18.04 LTS
Found the solution as follows. Supply the TERM=xterm as part of the ssh command
ssh -i ~/.ssh/privkey username#serverip TERM=xterm ./nodetimecheck.sh
When running
sudo docker run --net=host -t -e LICENSE=accept -v $(pwd):/installer/cluster ibmcom/icp-inception:2.1.0-ee install
I get fatal: [192.168.201.130] => Failed to connect to the host via ssh: Permission denied (publickey,password).
I have debugged the session:
root#icpecm:/opt/ibm-cloud-private-2.1.0/cluster# ssh -vvv -i cluster/ssh_key root#192.168.201.130
this is successful.
Have you copied the public key in all the nodes?
In your case:
$ ssh-copy-id -i .ssh/id_rsa root#192.168.201.130
i am wondering how does fabric execute commands.
Let's say I give him env.user=User, env.host=HOST. Then i ask him to sudo('ls')
Is that equivalent to me typing in a shell : ssh User#host 'sudo(/bin/ls)'
or it's more : ssh User#host in a first time, then sudo ls commande in a seconde time ?
I'm asking that because sometimes using a shell, if the TTY has a bad configuration (I am a bit blurry on this), ssh User#Host 'sudo /bin/ls'
return : sudo: no tty present and no askpass program specified
but you can first log in with ssh User#Host then sudo ls and it works.
I don't know how to replicate the no tty error, but I know it can occurs. Would this block the sudo commande from Fabric?
Basically how it works is:
First a connection is established (equivalent as doing ssh User#host)
Over this connection a command is executed as follows:
sudo -S -p 'sudo password:' /bin/bash -l -c "your_command"
You can also allow Fabric not to request a pty with either pty=False argument, env.always_use_pty=False or --no-pty commandline option.
I wanted to achieve the following task:
step 1: ssh to the remote server
step 2: ssh to a node connected to that server
step 3: change to a particulat directory of that node
I was looking for a ssh one liner and issued the following command
ssh -t -t user#remote.server "ssh node; cd /my/directory/"
However, the last cd command did not work. I am still in my home
directory of the node in remote server. I tried to remove the ";" part,
and issued the following one liner:
ssh -t -t user#remote.server "ssh node cd /my/directory/"
No success. The message was "Connection to remote.server closed"
I was wondering whether it is possible to achieve this task
using an ssh one liner.
Thanking you in advance for your inputs
I was close and could have played around a little bit more.
This page helped, and apparently the following syntax worked:
ssh -t user#remote.server "ssh -t node 'cd /my/directory/ ; bash'"
However, I do not understand the role of the "bash" part.