Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29543

SSH from EC2 to itself by different user which is not ec2-user

$
0
0

I'm newbie in AWS and need some help. I created user (ronen) in my EC2 instance (In addition to the ec2-user) by the adduser command. Then I created public/private key by the following command:

ssh-keygen -b 1024 -f my-cmd-gen-keys -t dsa

The following files created:

my-cmd-gen-keys
my-cmd-gen-keys.pub

I copied the content of the public file to /home/ronen/.ssh/authorized_keys. Then I tried to execute the command and got permission denied:

**

> ssh -i ronen-key-pair ronen@ip-172-31-19-13 
> Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

**

(I must to confess that it worked for me few days ago before I terminated the instance, probably missing something)

below is the command with -v option

> [ronen@ip-172-31-19-13 ~]$ ssh -i ronen-key-pair ronen@ip-172-31-19-13 -v

> OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017 debug1: Reading configuration data /etc/ssh/ssh_config > debug1: /etc/ssh/ssh_config
    > line 58: Applying options for * debug1: Connecting to ip-172-31-19-13
    > [172.31.19.13] port 22. debug1: Connection established. debug1:
    > identity file ronen-key-pair type 2 debug1: key_load_public: No such
    > file or directory debug1: identity file ronen-key-pair-cert type -1
    > debug1: Enabling compatibility mode for protocol 2.0 debug1: Local
    > version string SSH-2.0-OpenSSH_7.4 debug1: Remote protocol version
    > 2.0, remote software version OpenSSH_7.4 debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000 debug1: Authenticating to
    > ip-172-31-19-13:22 as 'ronen' debug1: SSH2_MSG_KEXINIT sent debug1:
    > SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256
    > debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex:
    > server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit>
    > compression: none debug1: kex: client->server cipher:
    > chacha20-poly1305@openssh.com MAC: <implicit> compression: none
    > debug1: kex: curve25519-sha256 need=64 dh_need=64 debug1: kex:
    > curve25519-sha256 need=64 dh_need=64 debug1: expecting
    > SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256
    > SHA256:gQm7jn7pje2jeEY+LrwW2BIWuS/7qF+QfI6HQ9JZ5Jw debug1: Host
    > 'ip-172-31-19-13' is known and matches the ECDSA host key. debug1:
    > Found key in /home/ronen/.ssh/known_hosts:1 debug1: rekey after
    > 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting
    > SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey after
    > 134217728 blocks debug1: SSH2_MSG_EXT_INFO received debug1:
    > kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
    > debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that
    > can continue: publickey,gssapi-keyex,gssapi-with-mic debug1: Next
    > authentication method: gssapi-keyex debug1: No valid Key exchange
    > context debug1: Next authentication method: gssapi-with-mic debug1:
    > Unspecified GSS failure.  Minor code may provide more information No
    > Kerberos credentials available (default cache:
    > KEYRING:persistent:1001)
    > 
    > debug1: Unspecified GSS failure.  Minor code may provide more
    > information No Kerberos credentials available (default cache:
    > KEYRING:persistent:1001)
    > 
    > debug1: Next authentication method: publickey debug1: Offering DSA
    > public key: ronen-key-pair debug1: Authentications that can continue:
    > publickey,gssapi-keyex,gssapi-with-mic debug1: No more authentication
    > methods to try. Permission denied
    > (publickey,gssapi-keyex,gssapi-with-mic).

Below is the directory/files permission of this user:

[ronen@ip-172-31-19-13 ~]$ ls -lrtaR
.:
total 24
-rw-r--r-- 1 ronen ronen  231 Jul 27  2018 .bashrc
-rw-r--r-- 1 ronen ronen  193 Jul 27  2018 .bash_profile
-rw-r--r-- 1 ronen ronen   18 Jul 27  2018 .bash_logout
drwxr-xr-x 4 root  root    35 Jan 27 17:42 ..
-rw-r--r-- 1 ronen ronen  641 Jan 27 17:44 ronen-key-pair.pub
-rw------- 1 ronen ronen  672 Jan 27 17:44 ronen-key-pair
drwxrwxr-x 2 ronen ronen   48 Jan 27 17:49 .ssh
-rw-rw-r-- 1 ronen ronen    0 Jan 27 18:56 client
-rw-rw-r-- 1 ronen ronen    0 Jan 27 18:56 server
drwx------ 3 ronen ronen  171 Jan 27 18:56 .
-rw------- 1 ronen ronen 3539 Jan 27 18:58 .bash_history

./.ssh:
total 8
-rw-rw-r-- 1 ronen ronen 641 Jan 27 17:45 authorized_keys
drwxrwxr-x 2 ronen ronen  48 Jan 27 17:49 .
-rw-r--r-- 1 ronen ronen 380 Jan 27 17:55 known_hosts
drwx------ 3 ronen ronen 171 Jan 27 18:56 ..
[ronen@ip-172-31-19-13 ~]$

Thank you for your help, Ronen


Viewing all articles
Browse latest Browse all 29543

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>