[英]authorized_keys does not present for new user
I want to setup an ssh key in a machine of Linux running under AWS in EC2 cloud. 我想在EC2云中的AWS下运行的Linux机器中设置ssh密钥。
For that firstly, I installed cygwin , then I followed the following steps : 为此,我先安装了cygwin ,然后执行以下步骤:
ssh-keygen -t dsa -f ~/.ssh/<key name> -C "<username of remote server>@<ip>"
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) 在此之前,我以root模式连接到远程计算机并创建了我在命令1、2(用户名)中指定的用户。
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 . 而且我看到该文件在我明确创建的用户的远程服务器中不存在,但对于用户root却存在。
When you create a new linux instance, you specify a key pair that you want to use. 创建新的Linux实例时,请指定要使用的密钥对。 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. ec2-user可能会有所不同,具体取决于您用于创建实例的AMI-例如,ubuntu是ubuntu实例的默认用户。
bash: /home//.ssh/authorized_keys: No such file exists
bash:/home//.ssh/authorized_keys:不存在此类文件
When you create a new user, the ~/.ssh
directory is not created him by default. 创建新用户时,默认情况下不会创建
~/.ssh
目录。 You have create it. 您已经创建了。 Then you have to create
~/.ssh/authorized_keys
file where you will copy the public key. 然后,您必须创建
~/.ssh/authorized_keys
文件,在其中复制公共密钥。
On your server, check whether ~/.ssh
or ~/.ssh/authorized_keys
exists. 在您的服务器上,检查
~/.ssh
或~/.ssh/authorized_keys
存在。 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
因此,如果您有一个名为
user1
,那么它将是/home/user1/.ssh
或/home/user1/.ssh/authorized_keys
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.