Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
550 views
in Technique[技术] by (71.8m points)

BASH Script - SCP - Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password)

I was requested for work to have a server that kinda acts like a backup for specific files mostly around 30 (cannot bind them together to a folder) they are scattered all over the server need to reach them individually. Before I'm inserting to the production environment - I have decided to try it at home

I have generated and copy the keys between both servers. I have changed folder and files permissions to the maximum required - even did 760 for testing purposes I have chmod 0770 to the all .ssh folder and still, get this annoying error also for both servers

I'm not using a Kerberos method or another programming interface - that requires me the GSSAPI - just a simple SCP

when I'm doing a manual SCP from test-server to linuxproject server it succeeds with no interruptions So I believe it has something to do with the second SSH process that comes from the SCP As when I'm accessing to test server for example - I'm able to execute commands before the SCP like creating a file (so issue happen I believe, when test-server tried to connect with the linuxproject server)

Below ERRORS I'm getting

Command:

[linuxproject@sysadmin ~]$ sshpass -p "abc12345" ssh [email protected] " touch longlist.txt && scp longlist.txt [email protected]:/home/linuxproject"

ERROR:

Permission denied, please try again.
    Permission denied, please try again.
    [email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
    lost connection

Some verbosity logs from the SCP command

debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup gssapi-keyex
debug3: remaining preferred: gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-keyex
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug2: we did not send a packet, disable method
debug3: authmethod_lookup gssapi-with-mic
debug3: remaining preferred: publickey,keyboard-interactive,password
debug3: authmethod_is_enabled 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_1000)


debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)


debug2: we did not send a packet, disable method
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/oren/.ssh/id_rsa RSA SHA256:tguZWskKp6IFsqdZ5cb/AqzFBd7hzsMXRhjd02wGqko
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/oren/.ssh/id_dsa
debug3: no such identity: /home/oren/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/oren/.ssh/id_ecdsa
debug3: no such identity: /home/oren/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/oren/.ssh/id_ed25519
debug3: no such identity: /home/oren/.ssh/id_ed25519: No such file or directory
debug1: Trying private key: /home/oren/.ssh/id_xmss
debug3: no such identity: /home/oren/.ssh/id_xmss: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

Please Please help me - I'm stuck for over 4 days with this (100 bad words) you know what- and can't get it solved

question from:https://stackoverflow.com/questions/65624100/bash-script-scp-permission-denied-publickey-gssapi-keyex-gssapi-with-mic-pa

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From my experience 0770 are the wrong permissions. SSH is somewhat picky about permissions. You should use it like this

user@server:~$ ls -la .ssh
total 28
drwx------  2 user group 4096 Nov 30 17:34 .
drwxr-xr-x 59 user group 4096 Jan  8 08:00 ..
-rw-r--r--  1 user group  394 May  5  2016 authorized_keys
-rw-------  1 user group 1675 May 10  2016 id_rsa
-rw-r--r--  1 user group  390 May 10  2016 id_rsa.pub

This is also stated in the SSH Documentation

~/.ssh/ This directory is the default location for all user-specific configuration and authentication information. There is no general requirement to keep the entire contents of this directory secret, but the recommended permissions are read/write/execute for the user, and not accessible by others.

~/.ssh/id_rsa Contains the private key for authentication. These files contain sensitive data and should be readable by the user but not accessible by others (read/write/execute). ssh will simply ignore a private key file if it is accessible by others.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...