I have command to execute on Linux: sudo ssh -L 80:localhost:80 -f -N root@10.19.34.11
There are three options that in some case I get them and some not:
password for jenkins user:"[sudo] password for jenkins:"answer is "yes or no" to the following:" The authenticity of host '10.19.34.11 (10.19.34.11)' can't be established. ECDSA key fingerprint is SHA256:96RyrUn7+VMF78YamjgCYYDwD0bzYDaMwHP4YFuQF4Q. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.19.34.11' (ECDSA) to the list of known hosts. ############################################################################ WARNING: This system is for the use of authorized clients only. Individuals using the computer network system without authorization, or in excess of their authorization, are subject to having all their activity on this computer network system monitored and recorded by the system personnel. To protect the computer network system from unauthorized use and to ensure the computer network systems is functioning properly, system administrators monitor this system. Anyone using this computer network system expressly consents to such monitoring and is advised that if such monitoring reveals possible conduct of criminal activity, system personnel may provide the evidence of such activity to law enforcement officers. ############################################################################ "password for the remote machine:"Password:"
In some cases I need to write just the first, second and third. Some cases: first and third. Some other cases just third.
Can you suggest command line or shel script for dealing with different optional input/output like here?
I have tried the following
#!/usr/bin/expectset asms_ip [lindex $argv 0]set pass_word algosecspawn sudo ssh -L 80:localhost:80 -f -N root@$asms_ipexpect "password for jenkins"send -- "$pass_word\r"expect "yes/no"send -- "yes\r"expect "Password:"send -- "$pass_word\r"expect eof
However it seems the last password is not working:
jenkins@jenkins-virtual-machine:~/test$ ./port_forward.sh 10.5.4.4spawn sudo ssh -L 80:localhost:80 -f -N root@10.5.4.4[sudo] password for jenkins:############################################################################ WARNING: This system is for the use of authorized clients only. Individuals using the computer network system without authorization, or in excess of their authorization, are subject to having all their activity on this computer network system monitored and recorded by the system personnel. To protect the computer network system from unauthorized use and to ensure the computer network systems is functioning properly, system administrators monitor this system. Anyone using this computer network system expressly consents to such monitoring and is advised that if such monitoring reveals possible conduct of criminal activity, system personnel may provide the evidence of such activity to law enforcement officers.############################################################################Password:Password: jenkins@jenkins-virtual-machine:~/test$