I have aws instance key .pem file I saved that in a folder
"home/debian/cs605\ data\ management/assignment6/mumbai\ instance\ keys"
the key name is mumbai-instance-1.pem
I wrote a small bash script like this
!/bin/bash
AWS_KEY="home/debian/cs605\ data\ management/assignment6/mumbai\ instance\ keys"
ssh -v -i $AWS_KEY/mumbai-instance-1.pem
[email protected]
the above file was saved named mumbai in following folder
/home/debian/cs605 data management/assignment6
now I try to launch the script after chmox +x mumbai
but I am getting error
Warning: Identity file home/debian/cs605\ not accessible: No such file or directory.
OpenSSH_8.0p1 Ubuntu-6build1, OpenSSL 1.1.1c 28 May 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
ssh: Could not resolve hostname data\\: Name or service not known
./mumbai: line 6: [email protected]: command not found
so what is this error and how can I get rid of this.
update 1
I tried the method mentioned in answer
debian@osboxes:~/cs605 data management/assignment6$ ./mumbai
Warning: Identity file home/debian/cs605 data management/assignment6/mumbai instance keys/mumbai-instance-1.pem not accessible: No such file or directory.
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]
[-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
[-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]
[-i identity_file] [-J [user@]host[:port]] [-L address]
[-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
[-Q query_option] [-R address] [-S ctl_path] [-W host:port]
[-w local_tun[:remote_tun]] destination [command]
./mumbai: line 6: [email protected]: command not found
I checked the permissions of file
debian@osboxes:~/cs605 data management/assignment6/mumbai instance keys$ ls -l
total 8
-rwxr-xr-x 1 debian debian 1692 Mar 3 14:24 mumbai-instance-1.pem
-rwxrw-rw- 1 debian debian 1464 Mar 3 14:30 mumbai-instance-pvt.ppk
so I don't think this should be a permissions issue.
I did a mistake above in AWS_KEY it should be /home
update2
Now while fixing the above issues I get following when I execute the above script with AWS_KEY="/home/debian/cs605\ data\ management/assignment6/mumbai\ instance\ keys"
debian@osboxes:~/cs605 data management/assignment6$ ./mumbai
OpenSSH_8.0p1 Ubuntu-6build1, OpenSSL 1.1.1c 28 May 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to ec2-xx-xxx-xx-xxx.ap-south-1.compute.amazonaws.com [xx-xxx-xx-xxx] port 22.
debug1: Connection established.
debug1: identity file /home/debian/cs605 data management/assignment6/mumbai instance keys/mumbai-instance-1.pem type -1
debug1: identity file /home/debian/cs605 data management/assignment6/mumbai instance keys/mumbai-instance-1.pem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.0p1 Ubuntu-6build1
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug1: Authenticating to ec2-xx-xxx-xx-xxx.ap-south-1.compute.amazonaws.com:22 as 'ec2-user'
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: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:q5biO+y+QovuhX7TUfVShKOh7nQ/TaVUPhs8YI8EJOs
The authenticity of host 'ec2-xx-xxx-xx-xxx.ap-south-1.compute.amazonaws.com (xx-xxx-xx-xxx)' can't be established.
ECDSA key fingerprint is SHA256:q5biO+y+QovuhX7TUfVShKOh7nQ/TaVUPhs8YI8EJOs.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'ec2-xx-xxx-xx-xxx.ap-south-1.compute.amazonaws.com,xx-xxx-xx-xxx' (ECDSA) to the list of known hosts.
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: debian@osboxes RSA SHA256:iFf3gBtMBnZsrEYwqUEZBanwk9vj6/nf64NfpGerACU agent
debug1: Will attempt key: /home/debian/cs605 data management/assignment6/mumbai instance keys/mumbai-instance-1.pem explicit
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-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1001)
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1001)
debug1: Next authentication method: publickey
debug1: Offering public key: debian@osboxes RSA SHA256:iFf3gBtMBnZsrEYwqUEZBanwk9vj6/nf64NfpGerACU agent
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Trying private key: /home/debian/cs605 data management/assignment6/mumbai instance keys/mumbai-instance-1.pem
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0755 for '/home/debian/cs605 data management/assignment6/mumbai instance keys/mumbai-instance-1.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/home/debian/cs605 data management/assignment6/mumbai instance keys/mumbai-instance-1.pem": bad permissions
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
ok I fixed it the key file should have 700 permission and 750 or 755 is not acceptible.
It's because of the white space in your path, in that case you have to use quotes.
Try this way:
Just remove extra slashes in variable
$AWS_KEY
and use""
when you use it.