If you have SSH installed, you should be able to run..
ssh-keygen
Then go through the steps, you'll have two files, id_rsa and id_rsa.pub (the first is your private key, the second is your public key - the one you copy to remote machines)
Then, connect to the remote machine you want to login to, to the file ~/.ssh/authorized_keys add the contents of your that id_rsa.pub file.
Oh, and chmod 600 all the id_rsa* files (both locally and remote), so no other users can read them:
chmod 600 ~/.ssh/id_rsa*
Similarly, ensure the remote ~/.ssh/authorized_keys file is chmod 600 also:
chmod 600 ~/.ssh/authorized_keys
Then, when you do ssh remote.machine, it should ask you for the key's password, not the remote machine.
To make it nicer to use, you can use ssh-agent to hold the decrypted keys in memory - this means you don't have to type your keypair's password every single time. To launch the agent, you run (including the back-tick quotes, which eval the output of the ssh-agent command)
`ssh-agent`
On some distros, ssh-agent is started automatically. If you run echo $SSH_AUTH_SOCK and it shows a path (probably in /tmp/) it's already setup, so you can skip the previous command.
Then to add your key, you do
ssh-add ~/.ssh/id_rsa
and enter your passphrase. It's stored until you remove it (using the ssh-add -D command, which removes all keys from the agent)
发布评论
评论(2)
如果你安装了 SSH,你应该能够运行..
然后完成这些步骤,你将有两个文件,
id_rsa
和id_rsa.pub
(第一个是您的私钥,第二个是您的公钥 - 您复制到远程计算机的密钥)然后,连接到您要登录的远程计算机,在文件
~/.ssh/authorized_keys
中添加id_rsa.pub
文件的内容。哦,还有
chmod 600
所有id_rsa*
文件(本地和远程),这样其他用户就无法读取它们:同样,确保远程
~/. ssh/authorized_keys
文件是chmod 600
也:然后,当您执行
ssh remote.machine
时,它应该询问您密钥的密码,而不是远程计算机的密码。为了使其更好用,您可以使用 ssh-agent 将解密的密钥保存在内存中 - 这意味着您不必每次都输入密钥对的密码。 要启动代理,您可以运行(包括反引号,它评估 ssh-agent 命令的输出)
在某些发行版上,ssh-agent 会自动启动。 如果您运行 echo $SSH_AUTH_SOCK 并显示一个路径(可能在 /tmp/ 中),则它已经设置,因此您可以跳过上一个命令。
然后要添加密钥,您需要
输入密码。 它会一直存储,直到您将其删除(使用 ssh-add -D 命令,该命令会从代理中删除所有密钥)
If you have SSH installed, you should be able to run..
Then go through the steps, you'll have two files,
id_rsa
andid_rsa.pub
(the first is your private key, the second is your public key - the one you copy to remote machines)Then, connect to the remote machine you want to login to, to the file
~/.ssh/authorized_keys
add the contents of your thatid_rsa.pub
file.Oh, and
chmod 600
all theid_rsa*
files (both locally and remote), so no other users can read them:Similarly, ensure the remote
~/.ssh/authorized_keys
file ischmod 600
also:Then, when you do
ssh remote.machine
, it should ask you for the key's password, not the remote machine.To make it nicer to use, you can use
ssh-agent
to hold the decrypted keys in memory - this means you don't have to type your keypair's password every single time. To launch the agent, you run (including the back-tick quotes, which eval the output of thessh-agent
command)On some distros, ssh-agent is started automatically. If you run
echo $SSH_AUTH_SOCK
and it shows a path (probably in /tmp/) it's already setup, so you can skip the previous command.Then to add your key, you do
and enter your passphrase. It's stored until you remove it (using the
ssh-add -D
command, which removes all keys from the agent)对于 Windows 这 是一个很好的介绍和指南
这里有一些适用于 Linux 以外系统的优秀 ssh 代理。
For windows this is a good introduction and guide
Here are some good ssh-agents for systems other than linux.