आपको केवल क्रॉस-प्लेटफ़ॉर्म ssh
कमांडलाइन टूल, ssh-keygen
और चाहिए ssh-copy-id
। विंडोज के लिए git में उन्हें शामिल किया गया है।
या तो गिट-स्थापित bash
शेल से ऐसा करें :
#By default this puts keyfile pair in ~/.ssh/id_rsa & ~/.ssh/id_rsa.pub :
ssh-keygen.exe -t rsa -b 2048
ssh-copy-id -i ~/.ssh/id_rsa.pub $remoteuser@$remotehost
# These two chmod lines are needed on unix platforms, probably not on Windows.
# typically ssh refuses to use a private key file
# if it is less-well protected than this:
chmod 700 ~/.ssh
chmod 640 ~/.ssh/id_rsa
या इस स्क्रिप्ट को PowerShell में चलाएं:
Param(
[Parameter()][string]$keyfile="id_rsa",
[Parameter()][string]$remotehost,
[Parameter()][string]$remoteuser
)
write-host "# ---------------------------------------------------------------------------------#"
write-host "# Create an RSA public/private key pair, and copy the public key to remote server #"
write-host "# #"
write-host "# /superuser/96051 #"
write-host "# ssh-from-windows-to-linux-without-entering-a-password/1194805#1194805 #"
write-host "# #"
write-host "# ---------------------------------------------------------------------------------#"
write-host "Keyfile pair will be saved at : ~/.ssh/$keyfile, ~/.ssh/$keyfile.pub"
write-host "And copied to $remoteuser@$remotehost"
write-host ""
write-host "You will need a password for the copy operation."
write-host ""
if( -not $(ls ~/.ssh) ) { mkdir ~/.ssh }
$sshdir=$(get-item ~/.ssh/).Fullname
#By default this puts keyfile pair in ~/.ssh/id_rsa & ~/.ssh/id_rsa.pub :
ssh-keygen.exe -t rsa -b 2048 -f "$sshdir$keyfile"
# ssh-copy-id somehow didn't work in Powershell so I called it via bash
bash -c "ssh-copy-id -i ~/.ssh/$keyfile.pub $remoteuser@$remotehost"
# I'm not sure if these two chmod lines work on windows but
# typically ssh refuses to use a private key file
# if it is less-well protected than this:
chmod.exe 700 $sshdir
chmod.exe 640 "$sshdir$keyfile"
इसके बाद, पासवर्ड रहित लॉगिन को दोनों ssh
और के लिए काम करना चाहिए scp
।