Using SSH keys in Linux/en: Difference between revisions

Jump to navigation Jump to search
Updating to match new version of source page
(Updating to match new version of source page)
(Updating to match new version of source page)
Line 11: Line 11:


<source lang="console">
<source lang="console">
[name@server]$ ssh-keygen -b 2048 -t rsa
[name@server]$ ssh-keygen -b 4096 -t rsa
</source>
</source>
(this example explicitly asks for a 2kbit RSA key, which is a reasonable choice.)
(this example explicitly asks for a 4-kbit RSA key, which is a reasonable choice.)


The output will be similar to the following:
The output will be similar to the following:
Line 51: Line 51:


If necessary, you can do this "manually" - in fact, ssh-copy-id isn't doing anything very magic.  It's simply connecting to the remote machine, and placing the public key into <code>.ssh/authorized_keys</code> in your home directory there.  The main benefit from using <code>ssh-copy-id</code> is that it will create files and directories if necessary, and will ensure that the permissions on them are correct.  You can do it entirely yourself by copying the public key file to the remote server, then:
If necessary, you can do this "manually" - in fact, ssh-copy-id isn't doing anything very magic.  It's simply connecting to the remote machine, and placing the public key into <code>.ssh/authorized_keys</code> in your home directory there.  The main benefit from using <code>ssh-copy-id</code> is that it will create files and directories if necessary, and will ensure that the permissions on them are correct.  You can do it entirely yourself by copying the public key file to the remote server, then:
<code>
<source lang="bash">
mkdir ~/.ssh
mkdir ~/.ssh
cat id_rsa.pub >> ~/.ssh/authorized_keys
cat id_rsa.pub >> ~/.ssh/authorized_keys
chmod --recursive go-rwx .ssh
chmod --recursive go-rwx ~/.ssh
chmod go-w ~
chmod go-w ~
</code>
</source>
SSH is picky about permissions, on both the client and the server.  SSH will fail if the following conditions are not met:
SSH is picky about permissions, on both the client and the server.  SSH will fail if the following conditions are not met:
<ul>
<ul>
38,760

edits

Navigation menu