我可以使用用户名和密码登录客户端。我知道 ssh 密钥更好、更安全,但现在我仍然想使用密码来执行此操作。
[michael@devserver ~]$ ssh -p 3333 -D 3333 testuser@localhost
testuser@localhost's password:
bind: Address already in use
channel_setup_fwd_listener: cannot listen to port: 3333
Could not request local forwarding.
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Nov 16 17:46:54 2017 from localhost
testuser@mypi:~ $
我想做同样的事情,但是在脚本中。我的尝试如下。但是,当我尝试时,系统仍然提示我输入密码。稍后我还将尝试使用 ssh 密钥来执行此操作,如我的注释行中所示。
#!/bin/sh
userServer='serveruser'
userClient='clientuser'
passwordServer='serverpassword'
passwordClient='clientpassword'
passwordClient=3333
if echo $passwordClient | ssh -p $port $userClient@localhost | grep ECDSA; then
# or if keys are used:
# if su -c "ssh -p $port $userClient@localhost" $userServer | grep ECDSA; then
echo 'Logon successful'
else
echo 'Connection refused'
fi