ทั้งหมดที่คุณต้องเป็นข้ามแพลตฟอร์มssh
เครื่องมือ commandline, และssh-keygen
ssh-copy-id
git สำหรับ Windows รวมไว้ด้วย
ทำสิ่งนี้จากbash
เชลล์ที่ติดตั้ง git :
#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"
หลังจากนี้เข้าสู่ระบบ passwordless ควรจะทำงานให้ทั้งสองและssh
scp