大网数据广告活动
服务器运维问答

How to automate ssh password Windows / Git bash - already with the installed software without needing to install

· 52CE 我爱测

I have a VM that has the fixed snapshot, and I have not the right to install anything How I can achieve the goal? Passing password to ssh connection Windows 10, using git bash without needing to install anything and without needi…

问题原文

原帖链接 · Nusrat Nuriyev · CC BY-SA 4.0

I have a VM that has the fixed snapshot, and I have not the right to install anything How I can achieve the goal?

Passing password to ssh connection Windows 10, using git bash without needing to install anything and without needing to input a password.

There might be actions that are done just once, but there can not be an action that is executed upon each double click of the script file. If I need to do anything except double-clicking (entering passing or adding a computer to trusted sources, fingerprint, executing ssh-agent, and so on).

Beautiful, simple , ubiquitous solution:

Here I will post what I have done so far, and what is not suitable.

Tried solution 1:

ssh-keygen ssh-copy-id [email omitted] ssh [email omitted]

Does not suit as it requires password but this time for key

Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/user/.ssh/id_rsa):

Tried solution 1.1

If I make something like this:

eval `ssh-agent`
# Add the identity (private key) to the agent
ssh-add /c/users/user/.ssh/id_rsa
ssh [email omitted]

the result is also not suitable:

Agent pid 2262 Enter passphrase for /c/users/user/.ssh/id_rsa:

Troubleshooting have been done:

The server might not be configured to accept public key authentication. Make sure /etc/ssh/sshd_config on the server contains PubkeyAuthentication yes. Remember to restart the sshd process on the server.

If trying to login as root, the server might not be configured to allow root logins. Make sure /etc/sshd_config includes PermitRootLogin yes, PermitRootLogin prohibit-password, or without-password. If it is set to forced-commands-only, the key must be manually configured to use a forced command (see command= option in ~/.ssh/authorized_keys.

Make sure the client allows public key authentication. Check that /etc/ssh/config includes PubkeyAuthentication yes.

Tried solution 2

If I make an empty password it still ask for password

[email omitted]'s password:

The goal is to pass my password the server without prompting.

What is the solution:

Actions that must be done once.

1.Create ssh key with ssh-keygen

ssh-keygen

1.1 input empty password and confirmation for ssh-keygen

  1. then create user@host : password association with ssh-copy-id command

.

ssh-copy-id [email omitted]

2.1 First, it will ask to add fingerprint of the server, write down "yes". It is done just once, to make sure that this host is trusted or rather regularly visited and within the list of known_hosts file.

2.2 It will ask password of the "[email omitted]". Please, do not confuse this password with the ssh-keygen generated password(which is empty) - they are different entities.

So this time just write the password for your remote host "[email omitted]"

Once you have done those steps, you may simply issue the following command to

ssh [email omitted]

and you are done, so you may simply start your server.sh file with a single line in it. This works for windows 10 + git bash

P.S. After restarting it works as expected when I start my server.sh file with a single line, it directly logs in without prompting password.

已采纳解答

原帖链接 · vidarlo · CC BY-SA 4.0

Does not suit as it requires password but this time for key

Remove passphrase on the key or generate a new one.

-p Requests changing the passphrase of a private key file instead of creating a new private key. The program will prompt for the file containing the private key, for the old passphrase, and twice for the new passphrase.

From man ssh-keygen.

Simply press enter when it asks for new passphrase.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-04-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。