How to SSH login password free from Windows, Linux, Mac

How to SSH login password free from Windows, Linux, Mac

It's very painful and annoying to always provide password for ssh login. But it can be fixed by auto password functionality of ssh

Akash Desarda's photo
Akash Desarda
·Feb 1, 2022·

1 min read

Play this article

Table of contents

  • 1. Linux OS & MAC OS
  • 2. Windows

1. Linux OS & MAC OS

Run the following command on your bash (or any alternative like zsh, fish, etc) to set up auto ssh login.

ssh-copy-id -i "<Public key path>" "<user.name@email.com@host_ip_adress>"

Example: Linux example

Output: Screenshot 2021-10-29 132602.png

2. Windows

Run the following commands, in a local PowerShell window replacing user and host name as appropriate to copy your local public key to the SSH host.

$USER_AT_HOST="your-user-name-on-host@hostname"
$PUBKEYPATH="$HOME\.ssh\id_rsa.pub"

$pubKey=(Get-Content "$PUBKEYPATH" | Out-String); ssh "$USER_AT_HOST" "mkdir -p ~/.ssh && chmod 700 ~/.ssh && echo '${pubKey}' >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"

Example: Screenshot 2021-10-29 132457.png

Output: image.png

 
Share this