如何使用SSH远程访问服务器?
How to get the remote access of server using SSH?
我正在尝试使用 SSH 命令远程访问我的服务器终端。但我面临错误。
我已经创建了我的“.ppk”文件并尝试这样做:
ssh -i MYFILE.ppk USER_NAME@192.188.28.109 -v -p 21098
我输入了正确的密码、用户名、IP地址和端口。我可以用腻子连接,但不能使用 terminal/CMD。
请提出建议。
我收到这个错误:
OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to 198.187.29.149 [198.187.29.149] port 21098.
debug1: Connection established.
debug1: identity file MYFILE.ppk type -1
debug1: identity file MYFILE.ppk-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000002
debug1: Authenticating to 198.187.29.149:21098 as 'USER_NAME'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<8192<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:LQPAAsZ1vHcK//jXTbyUFWmqQ3FEEpKgb8FV6jbjoZE
debug1: Host '[198.187.29.149]:21098' is known and matches the RSA host key.
debug1: Found key in /Users/utkarsh/.ssh/known_hosts:1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 4294967296 blocks
debug1: Will attempt key: MYFILE.ppk explicit
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: MYFILE.ppk
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for 'MYFILE.ppk' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "MYFILE.ppk": bad permissions
debug1: Next authentication method: password
MYFILE@198.187.29.149's password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.```
您收到的错误 WARNING: UNPROTECTED PRIVATE KEY FILE!
因为出于安全原因,私钥文件应该是只读文件。使用命令 chmod 400 MYFILE.ppk
分配 400 权限,然后重试应该有效的相同命令。
此外,使用 ssh
连接的推荐方法是获取 .pem
文件(如果您没有 .pem
文件,请转换您的 .ppk
)
请按照以下说明使用 ssh
进行连接。
- 将您的
.ppk
文件转换为 .pem
- 使用命令
chmod 400 my_file.pem
将权限更改为只读
- 使用命令连接远程服务器
ssh -i MYFILE.ppk USER_NAME@192.188.28.109 -v -p 21098
希望您的疑问得到解决。
我正在尝试使用 SSH 命令远程访问我的服务器终端。但我面临错误。 我已经创建了我的“.ppk”文件并尝试这样做:
ssh -i MYFILE.ppk USER_NAME@192.188.28.109 -v -p 21098
我输入了正确的密码、用户名、IP地址和端口。我可以用腻子连接,但不能使用 terminal/CMD。 请提出建议。
我收到这个错误:
OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to 198.187.29.149 [198.187.29.149] port 21098.
debug1: Connection established.
debug1: identity file MYFILE.ppk type -1
debug1: identity file MYFILE.ppk-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000002
debug1: Authenticating to 198.187.29.149:21098 as 'USER_NAME'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<8192<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:LQPAAsZ1vHcK//jXTbyUFWmqQ3FEEpKgb8FV6jbjoZE
debug1: Host '[198.187.29.149]:21098' is known and matches the RSA host key.
debug1: Found key in /Users/utkarsh/.ssh/known_hosts:1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 4294967296 blocks
debug1: Will attempt key: MYFILE.ppk explicit
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: MYFILE.ppk
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for 'MYFILE.ppk' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "MYFILE.ppk": bad permissions
debug1: Next authentication method: password
MYFILE@198.187.29.149's password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.```
您收到的错误 WARNING: UNPROTECTED PRIVATE KEY FILE!
因为出于安全原因,私钥文件应该是只读文件。使用命令 chmod 400 MYFILE.ppk
分配 400 权限,然后重试应该有效的相同命令。
此外,使用 ssh
连接的推荐方法是获取 .pem
文件(如果您没有 .pem
文件,请转换您的 .ppk
)
请按照以下说明使用 ssh
进行连接。
- 将您的
.ppk
文件转换为.pem
- 使用命令
chmod 400 my_file.pem
将权限更改为只读
- 使用命令连接远程服务器
ssh -i MYFILE.ppk USER_NAME@192.188.28.109 -v -p 21098
希望您的疑问得到解决。