Create a ssh key:
$ ssh-keygen -t rsa –P ""
Moving the key to authorized key:
$ cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys bash: /home/user/.ssh/authorized_keys: No such file or directory
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
bash: /home/user/.ssh/authorized_keys: No such file or directory
An element of the path
/home/user/.ssh/ does not exist; the shell (
bash) checks the redirection (
>>) before it executes the command (
/home/user does exist and you try this:
cat $HOME/.ssh/id_rsa.pub >> $HOME/test_this
You'll now get:
cat: /home/user/.ssh/id_rsa.pub: No such file or directory
Since that file can't be in that place, if
/home/user/.ssh/ did not exist to start with.
You're following some instructions having possibly skipped some bits. To create the directory:
mkdir $HOME/.ssh chmod 700 $HOME/.ssh
id_rsa.pub won't be there. It will be wherever you ran the
ssh-keygen command in the first place.
Make sure that you are logged in as the user that you want to create the ssh key for first (or be prepared to modify the paths in the command to the correct home directory).
Then just create the directory:
Create the file using the
cat command you have listed above. Then don't forget to set the permissions correctly:
chmod 400 ~/.ssh/authorized_keys
You might want to make sure that the .ssh directory has appropriate permissions as well.
If possible I always encourage people to use the commandline tool
$ ssh-copy-id -h Usage: /usr/bin/ssh-copy-id [-i [identity_file]] [user@]machine
If you just want to copy your default SSH public key to a remote sever you simply run the following command:
$ ssh-copy-id user@remoteserver
I show an actual full example of how to use this tool in this Q&A titled: Can't share an ssh connection with rsync.