新手问题 linux 下带着密钥登陆

lzm110 · March 04, 2013 · Last by lzm110 replied at March 12, 2013 · 3748 hits

在 linux 下登陆其他的服务器,怎么带着密钥登陆啊

在 windows 下,我们用 putty、winscp 直接指定密钥位置。在 linux 下怎么处理啊??

我是用 ssh -i privatekey.pem [email protected](或者 ip)......

#1 楼 @lhuang7

[root@xiaoshan36 temp]# ssh -i putty2013.ppk [email protected].. Enter passphrase for key 'putty2013.ppk': Enter passphrase for key 'putty2013.ppk': 这个要输入的是啥啊?好像不是密码啊?

这是你新建密钥对时输入的密码,如果是一路回车创建的,应该就是空

#3 楼 @goinaction 空是错的 但是在 windows 下登陆的时候,为什么直接指向文件就行了啊 不用这一步啊

应该是格式问题,你试试按照这个方式把 ppk 转换成 pem 的再试试 http://baoz.net/%E6%8A%8Appk%E8%BD%AC%E6%8D%A2%E4%B8%BApem-key/

#5 楼 @goinaction 我按照上面方式 保存的文件名为:2.pem 但是没有用,还是和上面的一样的提示错误

ssh-copy-id

#7 楼 @xds2000 什么意思 没看懂啊

#7 楼 @xds2000 现在连登陆都上不了 哪里来的 scp 啊??

苹果是 ssh-add ~/.ssh/id_rsa id_rsa 是你的密钥。你可以 ssh-add -l 看一下系统中的密钥。

#10 楼 @jimrokliu [root@xiaoshan36 temp]# ssh-add -l Could not open a connection to your authentication agent. You have new mail in /var/spool/mail/root [root@xiaoshan36 temp]#

╭─ligan@ligan-kfz  ~/.ssh ‹ruby-1.9.3› 
╰─$ ls
config   known_hosts   kongfz   kongfz.pub
╭─ligan@ligan-kfz  ~/.ssh ‹ruby-1.9.3› 
╰─$ cat config
Host 210
  HostName xxx.xxx.xxx.xxx
  User ligan
  IdentityFile ~/.ssh/kongfz

Host neibu
  HostName xxx.xxx.xxx.xxx
  Port 39999
  User ligan
  IdentityFile ~/.ssh/kongfz

或者

ssh username@ip -i your-key-position

putty 的 key 貌似要转换格式后使用

#11 楼 @lzm110 ps -ef |grep ssh-agent ,有没有 ssh-agent,没有的话你需要先启动 ssh-agent.

#13 楼 @jimrokliu [email protected][root@localhost 1]# ps -ef | grep ssh-a* root 8167 1 0 14:01 ? 00:00:00 /usr/bin/ssh-agent root 8227 8174 0 14:04 pts/3 00:00:00 grep ssh-a* [email protected][root@localhost 1]# ssh [email protected].. -i putty20130222_2.ppk Enter passphrase for key 'putty20130222_2.ppk': Permission denied (publickey,gssapi-with-mic). [email protected][root@localhost 1]#

#ssh-add -l 的结果时什么,我的是

LiuMacBook-Pro:~ liujiang$ ssh-add -l
1024 d8:94:2c:18:15:5e:60:2b:78:80:1e:5d:b8:78:24:2d /Users/liujiang/.ssh/ewhine_rsa (RSA)
LiuMacBook-Pro:~ liujiang$

ewhine_rsa 是我正在使用的密钥。

11 楼的数据就是我的结果

#16 楼 @lzm110 那你没有把秘钥加入,你密钥的文件名是什么?放在什么地方

#14 楼 @lzm110

chmod 600 putty20130222_2.ppk

另外,我不知道 putty 的 key 格式能不能直接用在 ssh 上。如果不是权限问题的话就用 puttygen 转换下格式

#18 楼 @flypiggys 不知道怎么转换啊 我按照 5 楼的转换过的 不知道是不是对的。

#5 楼 @goinaction 谢谢 5 楼 也谢谢大家 按照 5 楼的方法解决了问题了。

难得有帮上忙的时候😄

#21 楼 @goinaction 以后还要多多指教呢 哈哈

You need to Sign in before reply, if you don't have an account, please Sign up first.