ssh from Linux to Windows cygwin - ssh

I installed cygwin and configured openssh (ssh-host-config -y) on a Windows machine. Now from a Linux on the network I have a strange behavior:
without .ssh (on the Linux), I successfully connect with password
with .ssh (and my public key on the .ssh/authorized_keys of the Windows, I failed (and it doesn't ask me password):
ssh -v M3D#ipinria029
OpenSSH_5.9p1 Debian-5ubuntu1.4, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /home/lionel/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to ipinria029 [10.0.31.29] port 22.
debug1: Connection established.
debug1: identity file /home/lionel/.ssh/id_rsa type -1
debug1: identity file /home/lionel/.ssh/id_rsa-cert type -1
debug1: identity file /home/lionel/.ssh/id_dsa type 2
debug1: Checking blacklist file /usr/share/ssh/blacklist.DSA-1024
debug1: Checking blacklist file /etc/ssh/blacklist.DSA-1024
debug1: identity file /home/lionel/.ssh/id_dsa-cert type -1
debug1: identity file /home/lionel/.ssh/id_ecdsa type -1
debug1: identity file /home/lionel/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.7
debug1: match: OpenSSH_6.7 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.4
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 2a:4a:bc:24:bc:9e:c6:17:bb:f1:54:e1:03:df:7e:d4
debug1: Host 'ipinria029' is known and matches the ECDSA host key.
debug1: Found key in /home/lionel/.ssh/known_hosts:43
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering DSA public key: /home/lionel/.ssh/id_dsa
Connection closed by 10.0.31.29
Any suggestions?

Can you try moving your config and ssh_config files in ~/.ssh to a different location (temporarily)? I have a feeling that your config could be messing with it...
Other than that, could you please make sure that the authorized_keys in your windows is EXACTLY what is in ~/.ssh/id_dsa.pub on your linux machine?
If that dosent work, try running ssh-keygen, and putting the id_rsa file in the authorized hosts. (this will overwrite ~/.ssh/id_rsa) I've never used dsa for ssh keys before, I've always used RSA.

Related

GitLab clone over SSH not working on 'new machine'

I'm having issues cloning a repository on a new machine. While git clone over SSH works perfectly fine on a machine which I had already setup (a while ago), I've now added my public key in the GitLab GUI and try git clone git#, but without success. The fact that it works on my other machine, suggests a client-side issue to me. What I'm trying:
ssh -vT git#<DOMAIN_NAME>.de
OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to <DOMAIN_NAME>.de [141.89.97.171] port 22.
debug1: Connection established.
debug1: identity file <HOME_DIR>/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file <HOME_DIR>/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file <HOME_DIR>/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file <HOME_DIR>/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file <HOME_DIR>/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file <HOME_DIR>/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file <HOME_DIR>/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file <HOME_DIR>/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.10
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.10 pat OpenSSH_5* compat 0x0c000000
debug1: Authenticating to <DOMAIN_NAME>.de:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: ecdh-sha2-nistp256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: aes128-ctr MAC: umac-64#openssh.com compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: umac-64#openssh.com compression: none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:QUDzLMIelWfaGrqQjj9O7DLHHeW/1mG/+b8fYvXck34
debug1: Host '<DOMAIN_NAME>.de' is known and matches the ECDSA host key.
debug1: Found key in <HOME_DIR>/.ssh/known_hosts:1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: pubkey_prepare: ssh_get_authentication_socket: Permission denied
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: <HOME_DIR>/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: <HOME_DIR>/.ssh/id_dsa
debug1: Trying private key: <HOME_DIR>/.ssh/id_ecdsa
debug1: Trying private key: <HOME_DIR>/.ssh/id_ed25519
debug1: Next authentication method: password
git#<DOMAIN_NAME>.de's password:
I checked the public key in the GitLab GUI with the one in my .ssh/id_rsa.pub (they match), so I expect it to work without this password prompt. I've checked several SO posts (ssh clone not working with github) (I'm aware that gitlab and github are two different beasts), gitlab issue pages, etc., but haven't found a solution yet. Again; what particularly bothers me is that this is not working for an 'unseen' machine, and works for others, suggesting something on the client side. Still, I have restarted and reconfigured gitlab (gitlab-ctl restart and gitlab-ctl reconfigure) as well on the server, both before and after adding my new public key, but that didn't help either.
Any thoughts?
For future reference/anyone who runs into the same problem; I've fixed it with a gitlab-rake gitlab:shell:setup on the server that is hosting gitlab. No restart (of gitlab), reconfigure or re-generating/copying of the key file needed.

Launched new instance on EC2 with same keypair, can't ssh

This is on AWS. I tried to launch a new Ubuntu instance (#2) with the same keypair that is associated with another Ubuntu instance (#1).
AWS instances are associated with keypairs at the time they are launched and cannot be changed once launched.
I can connect to instance #1 but can't connect to instance #2 using the same ssh command. I've checked my permissions and everything seems to be ok.
The key is in ~/AMI.pem.
I have chmod 600 on my home directory and chmod 400 on ~/AMI.pem, so it's only readable/writeable by me.
The instances are nearly identical, with the same security groups and keypairs, same version of Ubuntu, etc. Instance #1 has some additional packages installed. I verified both are associated with the same keypair called "AMI".
Connecting to #2:
USAU9900:ScrapeEdgar reedn$ ssh -i ~/AMI.pem -v ubuntu#54.67.18.96
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/reedn/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to 54.67.18.96 [54.67.18.96] port 22.
debug1: Connection established.
debug1: identity file /Users/reedn/AMI.pem type -1
debug1: identity file /Users/reedn/AMI.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2
debug1: match: OpenSSH_6.2 pat OpenSSH*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm#openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm#openssh.com none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 36:69:f6:95:b4:3c:f0:77:02:ab:02:01:af:c7:cc:6a
debug1: Host '54.67.18.96' is known and matches the RSA host key.
debug1: Found key in /Users/reedn/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/reedn/AMI.pem
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
*Permission denied (publickey).*
Connecting to instance #1:
USAU9900:ScrapeEdgar reedn$ ssh -i ~/AMI.pem -v ubuntu#54.183.77.100
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/reedn/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to 54.183.77.100 [54.183.77.100] port 22.
debug1: Connection established.
debug1: identity file /Users/reedn/AMI.pem type -1
debug1: identity file /Users/reedn/AMI.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm#openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm#openssh.com none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA a6:53:a0:99:b8:61:ef:fe:05:d3:fe:47:90:ea:de:b6
The authenticity of host '54.183.77.100 (54.183.77.100)' can't be established.
RSA key fingerprint is a6:53:a0:99:b8:61:ef:fe:05:d3:fe:47:90:ea:de:b6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '54.183.77.100' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/reedn/AMI.pem
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
Authenticated to 54.183.77.100 ([54.183.77.100]:22)
First you need make sure the keypair has been applied to instance #2. Something like below in aws console on this instance:
Key pair name: AMI (should be same as instance #1)
Then try below steps:
If this ec2 instance is not in VPC, could you stop and start the instance to refresh with new public IP address and try again?
clean content in .ssh/known_hosts in your local machine, and try again.
One of them should work for you.

Trying to SSH into EC2 instance - permission denied

Logging to EC2 for first time via SSH.
It's not able to open private key file. So I changed chmod to 700 but its still throwing same error. Please suggest how can I fix it.
Macs-MacBook-Pro:~ Macbook$ ssh -v -i ~/.ssh/aug1981.pem ubuntu#ec2-54-200-94-18.us-west-2.compute.amazonaws.com
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to ec2-54-200-94-18.us-west-2.compute.amazonaws.com [54.200.94.18] port 22.
debug1: Connection established.
debug1: identity file /Users/Macbook/.ssh/aug1981.pem type -1
debug1: identity file /Users/Macbook/.ssh/aug1981.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH_5*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 8d:e2:20:42:95:c5:bc:14:42:10:a5:cf:40:d8:d9:fa
debug1: Host 'ec2-54-200-94-18.us-west-2.compute.amazonaws.com' is known and matches the RSA host key.
debug1: Found key in /Users/Macbook/.ssh/known_hosts:2
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/Macbook/.ssh/aug1981.pem
debug1: could not open key file '/Users/Macbook/.ssh/aug1981.pem': Permission denied
debug1: No more authentication methods to try.
Permission denied (publickey).
Where is the file located the you downloaded from your EC2 instance?
Can you do an ls -la on the dir with the .pem so we can see who owns the .pem file?
Also did you setup any security measures on the EC2 instance like 192.168.0.0/24 can access port 22/tcp of this instance?
You have a permission denied error for trying to open the keyfile.
I would do a ls -la and see if your user actually owns the file and that it is set to permissions 0700.
If it is not owned by your user the you need to:
whoami # this will tell you your user's name
chown user aug1981.pem

AWS- public key denied on opening ssh

I know there are alot of questions regarding AWS & SSH sessions, and I've attempted to make use of them, but all have failed.
I have an instance running, and the ssh string given by the EC2 Management Console is
ssh -i -v jason.pem ubuntu#ec2-54-227-167-156.compute-1.amazonaws.com
which produces the output
OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to ec2-54-227-167-156.compute-1.amazonaws.com [54.227.167.156] port 22.
debug1: Connection established.
debug1: identity file jason.pem type -1
debug1: identity file jason.pem-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian- 5ubuntu1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA ea:b6:50:fe:49:49:90:76:03:91:21:6d:73:0e:04:d2
debug1: Host 'ec2-54-227-167-156.compute-1.amazonaws.com' is known and matches the ECDSA host key.
debug1: Found key in /home/jason/.ssh/known_hosts:27
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Trying private key: jason.pem
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
I've done the following:
Created new keypair, downloaded jason.pem and set to 0400 chmod permissions
Added ChallengeResponseAuthentication yes to /etc/ssh/ssh_config
What exactly is going on, and why is the jason.pem file not being accepted?
The public key on your instance doesn't align with your private keypair. If that instance's configuration is important and you want to keep it (I say this based upon the fact that you shutdown the instance rather than just creating a new one):
Create a new keypair
Create an AMI of the instance you want to access
Create a new instance from that AMI using the new keypair
Attempt to ssh into it again using the new downloaded keypair
400 permissions should be fine for the keypair.

ssh to aws permission denied (public key) using ubuntu# why is it failing?

I can't seem to use SSH to connect to AWS although I don't usually have any problems with github or heroku. The debug is below, I've tried #ubuntu and #ec2-user (it should be #ubuntu), I've also tried creating a config file in .ssh (on windows) and adding 'ChallengeResponseAuthentication yes' as that seemed to fix it on another thread, but no luck. I've modified the permissions of the.pem file to 400. I don't understand why it says it all sounds positive but then fails, if I could get a better idea of what the error is I might be able to find a solution. Any help very much appreciated!
$ ssh -v -i futurebot2.pem ubuntu#ec2-54-218-75-37.us-west-2.compute.amazonaws.com
OpenSSH_6.2p2, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /home/Mark/.ssh/config
debug1: Connecting to ec2-54-218-75-37.us-west-2.compute.amazonaws.com [54.218.75.37] port 22.
debug1: Connection established.
debug1: identity file futurebot2.pem type -1
debug1: identity file futurebot2.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH_5*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA f2:cd:94:4d:a1:9a:b5:67:cb:f7:91:d7:ef:4d:a4:3d
debug1: Host 'ec2-54-218-75-37.us-west-2.compute.amazonaws.com' is known and matches the ECDSA host key.
debug1: Found key in /home/Mark/.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: futurebot2.pem
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
Two reasons why this might happen.
User does not exist, this might be due to connecting with the wrong user or an instance that is not your own (wrong ip address)
The user does not have your key in its authorized keys file. In AWS, the key you select at launch is added to your instance, but if you want to use other keys, you need to add them to your authorized_keys file manually.