Контекст :
Этот ответ дает интересную подсказку с использованием ssphass.
Что я установил в '~ / .ssh / config':
Host myServer
HostName 12.34.56.78
User bob
ProxyCommand sshpass -v -pmyPassword ssh %r@%h -W localhost:%p
NB: параметр sshpass '-v' нужен только для получения подробностей при задании этого вопроса.
Когда я пытаюсь подключиться через SSH:
me@myWorkstation$ ssh myServer
SSHPASS searching for password prompt using match "assword"
SSHPASS read: bob@12.34.56.78's password:
SSHPASS detected prompt. Sending password.
SSHPASS read:
bob@12.34.56.78's password:
И так ждет вечно :-(
Если я отредактирую '~ / .ssh / config' и заменю 'myPassword' (реальный пароль, привязанный к этому SSH-входу, работает при входе в систему вручную):
Host myServer
HostName 12.34.56.78
User bob
ProxyCommand sshpass -v -pnotMyPasswordAnymoreOhNo ssh %r@%h -W localhost:%p
который дает :
me@myWorkstation$ ssh myServer
SSHPASS searching for password prompt using match "assword"
SSHPASS read: bob@12.34.56.78's password:
SSHPASS detected prompt. Sending password.
SSHPASS read:
Permission denied, please try again.
SSHPASS read: bob@12.34.56.78's password:
SSHPASS detected prompt, again. Wrong password. Terminating.
ssh_exchange_identification: Connection closed by remote host
Я действительно получаю ответ (хотя и отрицательный). Не могли бы вы объяснить почему?
человек sshpass говорит:
СООБРАЖЕНИЯ БЕЗОПАСНОСТИ
First and foremost, users of sshpass should realize that ssh's insistance on only getting the password interac‐ tively is not without reason. It is close to impossible to securely store the password, and users of sshpass should consider whether ssh's public key authentication provides the same end-user experience, while involving less hassle and being more secure. The -p option should be considered the least secure of all of sshpass's options. All system users can see the password in the command line with a simple "ps" command. Sshpass makes a minimal attempt to hide the password, but such attempts are doomed to create race conditions without actually solving the problem. Users of sshpass are encouraged to use one of the other password passing techniques, which are all more secure. In particular, people writing programs that are meant to communicate the password programatically are encouraged to use an anonymous pipe and pass the pipe's reading end to sshpass using the -d option.
Вы можете попробовать сохранить переменную ENV и сохранить там проход, но это плохая практика.