jeudi 10 avril 2014

Linux - authorized_keys ne présente pour le nouvel utilisateur - Stack Overflow


I want to setup an ssh key in a machine of Linux running under AWS in EC2 cloud.


For that firstly, I installed cygwin, then I followed the following steps :



  1. ssh-keygen -t dsa -f ~/.ssh/<key name> -C "<username of remote server>@<ip>"

  2. cat ~/.ssh/<key name>.pub | ssh <username of remote server>@<ip> "cat >> ~/.ssh/authorized_keys"


Now the 1st statement executes successfully but the 2nd statement shows


bash: /home/<username of server>/.ssh/authorized_keys: No such file exists

Prior to this, I connected to the remote machine in root mode and created the user, that I am specifying at the command 1, 2 (username)


And I saw that the file is not present in the remote server for the user I created explicitly, but it is present for the user root.




When you create a new linux instance, you specify a key pair that you want to use. You have a choice of creating a key pair, and downloading the public key, or uploading a private key.


In your steps, you never reference the key pair you specified when you created the instance. So the 2nd command should be something like:


cat ~/.ssh/<key name>.pub | ssh -i ~/.ssh/<key specified when launching instance> ec2-user@<public id> ...

ec2-user may be different depending on what AMI you used to create your instance - ubuntu is the default user for ubuntu instances, for example.





bash: /home//.ssh/authorized_keys: No such file exists



When you create a new user, the ~/.ssh directory is not created him by default. You have create it. Then you have to create ~/.ssh/authorized_keys file where you will copy the public key.


On your server, check whether ~/.ssh or ~/.ssh/authorized_keys exists. Looking at hte error you have, it seems that it does not. So manualy create it.


BTW, ~ in above statement means User's home directory. So if you have user called user1, then it would be /home/user1/.ssh or /home/user1/.ssh/authorized_keys



I want to setup an ssh key in a machine of Linux running under AWS in EC2 cloud.


For that firstly, I installed cygwin, then I followed the following steps :



  1. ssh-keygen -t dsa -f ~/.ssh/<key name> -C "<username of remote server>@<ip>"

  2. cat ~/.ssh/<key name>.pub | ssh <username of remote server>@<ip> "cat >> ~/.ssh/authorized_keys"


Now the 1st statement executes successfully but the 2nd statement shows


bash: /home/<username of server>/.ssh/authorized_keys: No such file exists

Prior to this, I connected to the remote machine in root mode and created the user, that I am specifying at the command 1, 2 (username)


And I saw that the file is not present in the remote server for the user I created explicitly, but it is present for the user root.



When you create a new linux instance, you specify a key pair that you want to use. You have a choice of creating a key pair, and downloading the public key, or uploading a private key.


In your steps, you never reference the key pair you specified when you created the instance. So the 2nd command should be something like:


cat ~/.ssh/<key name>.pub | ssh -i ~/.ssh/<key specified when launching instance> ec2-user@<public id> ...

ec2-user may be different depending on what AMI you used to create your instance - ubuntu is the default user for ubuntu instances, for example.




bash: /home//.ssh/authorized_keys: No such file exists



When you create a new user, the ~/.ssh directory is not created him by default. You have create it. Then you have to create ~/.ssh/authorized_keys file where you will copy the public key.


On your server, check whether ~/.ssh or ~/.ssh/authorized_keys exists. Looking at hte error you have, it seems that it does not. So manualy create it.


BTW, ~ in above statement means User's home directory. So if you have user called user1, then it would be /home/user1/.ssh or /home/user1/.ssh/authorized_keys


0 commentaires:

Enregistrer un commentaire