How to make remote ssh non-interactive

I am trying to connect to a remote host from my local host using the command below. But a parameter was set on the remote host, which soon after logging in will ask you to enter the icon identifier, password and reason for logging in, because it was encoded as in the profile file on remote-host . How can I overcome these steps and log in directly without interacting without breaking code in the profile .

 jsmith@local-host $ ssh -t -t generic_userID@remote-host Enter your badgeID, < exit > to abort: Enter your password for <badgeID> : Enter a one line justification for your interactive login to generic_userID 
+4
source share
3 answers

Take a look at setting the script wrapper around expect . This should do exactly what you are looking for.

Here are some examples from which you can work.

+2
source

A small correction: to overcome the expected approach to a remote server, it is required, but if a local script connects to a group of remote servers, what configuration may be broken, just use the SSH parameters:

ssh -f -q -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null USER@TARGETSYSTEM

This will skip the password request, if there is no ssh_key setting, exit silently and continue using script / other hosts.

Places ssh in the background code with -f, which is required when the ssh command is called from the sh (batch) file to remove the local console with redirection to remote login (implies -n).

0
source

I got a response from Marvin Pinto because there is every reason for a script if there are other functions in the profile, such as Message of the day motd .

However, there is a quick and dirty alternative if you do not want to create a script and you do not need other functions from the profile. Depending on your preferred shell on the remote host, you may insist that the shell bypass profile files. For example, if bash is available on a remote host, you can invoke it with:

 ssh -t -t generic_userID@remote-host bash --noprofile 

I tested the above version of OpenSSH for macOS 10.13. Normally, the command at the end of the ssh call is run silently, but the -t flag allows bash to start the interactive shell.

See the "Launch Files" section of the Bash Reference Guide for details.

-1
source

Source: https://habr.com/ru/post/1486035/


All Articles