2016-04-27 107 views
0

我已經在Amazon EC2上安裝了一個tomcat,並且正在嘗試寫入/ home/ec2-user /文件夾中的一個文件夾。 但我沒有得到,因爲tomcat用戶有權限到該文件夾​​。通過ssh連接,無需訪問主文件夾

我試圖改變tomcat用戶的所有者,但都沒有。 我想也許文件夾/家/ ec2用戶/是問題,然後改變到該文件夾​​的權限...但沒有奏效。

在互聯網上搜索我發現了命令setenforce 0,但它沒有奏效。

然後我關閉會話,當我嘗試再次登錄收到以下消息

ssh -i "Amazon-Tomcat.pem" [email protected] 
Permission denied (publickey). 

我想,也許是因爲我有到/ home/EC2用戶/然後嘗試根本進不去但我得到

ssh -i "Amazon-Tomcat.pem" [email protected] 
Please login as the user "ec2-user" rather than the user "root". 

Connection to ec2-52-39-23-66.us-west-2.compute.amazonaws.com closed. 

,如果我在連接命令中使用-v收到以下消息

ssh -i "Amazon-Tomcat.pem" [email protected] -v 
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: /etc/ssh/ssh_config line 19: Applying options for * 
debug1: Connecting to ec2-52-39-23-66.us-west-2.compute.amazonaws.com [52.39.23.66] port 22. 
debug1: Connection established. 
debug1: identity file Amazon-Tomcat.pem type -1 
debug1: identity file Amazon-Tomcat.pem-cert type -1 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6 
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1 
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000 
debug1: SSH2_MSG_KEXINIT sent 
debug1: SSH2_MSG_KEXINIT received 
debug1: kex: server->client aes128-ctr [email protected] none 
debug1: kex: client->server aes128-ctr [email protected] none 
debug1: sending SSH2_MSG_KEX_ECDH_INIT 
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY 
debug1: Server host key: ECDSA 21:76:3c:72:dd:68:14:c5:83:a6:09:9a:80:26:74:bc 
debug1: Host 'ec2-52-39-23-66.us-west-2.compute.amazonaws.com' is known and matches the ECDSA host key. 
debug1: Found key in /home/rodrigo/.ssh/known_hosts:7 
debug1: ssh_ecdsa_verify: signature correct 
debug1: SSH2_MSG_NEWKEYS sent 
debug1: expecting SSH2_MSG_NEWKEYS 
debug1: SSH2_MSG_NEWKEYS received 
debug1: SSH2_MSG_SERVICE_REQUEST sent 
debug1: SSH2_MSG_SERVICE_ACCEPT received 
debug1: Authentications that can continue: publickey 
debug1: Next authentication method: publickey 
debug1: Offering RSA public key: OpenShift-Key 
debug1: Authentications that can continue: publickey 
debug1: Trying private key: Amazon-Tomcat.pem 
debug1: key_parse_private2: missing begin marker 
debug1: read PEM private key done: type RSA 
debug1: Authentications that can continue: publickey 
debug1: No more authentication methods to try. 
Permission denied (publickey). 

非常感謝您提出的任何建議,請原諒我的愚蠢

+1

我假設'Amazon-Tomcat.pem'是PEM格式的SSL客戶端證書。這也是證書的文件名嗎?根據ssh手冊頁,「ssh還會嘗試從通過將-cert.pub附加到標識文件名獲得的文件名加載證書信息。」所以也許你的文件需要命名爲「Amazon-Tomcat.pem-cert.pub」呢? (是的,這是一個奇怪的文件名,但是我只是在看了一下手冊頁後才猜出來。) –

+1

哦,爲什麼這個標記爲「膩子」?在問題中沒有putty,'ssh'語法看起來像OpenSSH語法。 –

+0

@AxelBeckert謝謝,但我從亞馬遜下載文件。我總是使用這些命令登錄 – user60108

回答

1

你已經在你的.ssh鍵公鑰錯誤地過於寬鬆,這意味着,ssh登錄過程拒絕工作

要做出的權限修復它,看到得分最高的回答這個問題Change key pair for ec2 instance

基本上,你必須從現在打破EC2磁盤安裝到一個新的EC2和修復

爲了解決原來的問題(Tomcat的寫入文件夾),給「其他x」訪問您的/ home/ec2用戶主文件夾t OP級

chmod o+x /home/ec2-user 

和「全部」訪問您的「文件夾」

chmod 777 /home/ec2-user/folder 

離開.ssh目錄等目錄不變

而且下一次測試的ssh你註銷前仍在工作!

1

如果您使用的是Mac或linux/unix風味機,請再次運行ssh命令,然後拖尾-f /var/log/auth.log。最後幾行會給出確切的錯誤信息。嘗試將密鑰對文件的權限更改爲600(運行chmod 600 Amazon-Tomcat.pem),然後再次嘗試ssh。