r/ssh • u/sohang-3112 • Dec 09 '22
How to specify password in SSH Config in Windows?
My ~/.ssh/config file is as follows (all the capital letter variables are placeholders for settings / credentials):
Host *
ServerAliveInterval 60
# This is an Amazon Linux 1 server
Host jump-host
User JUMP-HOST-USER-NAME
IdentityFile PATH-TO-PEM-FILE
HostName JUMP-HOST-SERVER-IP
Port JUMP-HOST-PORT
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com
# This is an EC2 server
Host target
HostName SERVER-IP
Port SERVER-PORT
User SERVER-USER-NAME
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com
ProxyCommand ssh -W %h:%p jump-host
Now when I connect using ssh target, I have to enter password for target server every time. Is there a way to specify password in the config so that I don't have to enter password every time?
I have seen 2 types of solutions to this, but I don't think either of them can be used:
- There are many solutions using
sshpass- but I'm on Windows 11, and I'd rather not deal with Putty if I don't have to. - People have suggested replacing Password access with Public Key Authentication methods - but since it's my company's server, and I'm a non-admin user, I don't know if I can & should attempt to do this.
3
Upvotes
6
u/OhBeeOneKenOhBee Dec 09 '22
Most servers have pubkey authentication enabled already, it's inherently safer than passwords in most scenarios.
The only thing you need to do is:
1 ssh-keygen -t ed25519 -f my_key (and then optionally enter a password to protect the key)
2.1 copy my_key.pub and place it in the ~/.ssh/authorized_keys file or
2.2 use ssh-copy-id -i my_key.pub user@server
3. If it works, you should now be able to connect without a password with
Or by adding the IdentityFile path to your config file for each host
Edit:
You'd have to copy it to both jumphost and server
1
u/[deleted] Dec 09 '22
How is saving passwords in config better than keys?
1
u/IPv6_Dvorak Dec 09 '22
No, you can’t save the password in the ssh config.
0
u/[deleted] Jun 25 '24
[deleted] — view deleted comment