FreeTstar

loving Freedom + + loving Linux

  • 首页
  • Archive
  • 关于
  • 杂七杂八
  • 留言板
Twitter Sina RSS

小记:Linux下设置ssh免认证登录服务器

发布于 2010年08月16日 由 freetstar
13 条评论发表评论

ssh免认证登录,可以省去输入密码的交互过程,方便实现自动执行一些无需职守程

特以设置本PC登录远程VPS为例

方法如下:

第一步:客户机

//生成密钥对,-t 指明生成密钥类型为rsa ,-P表示设置私钥的密码,设为空,-f设置密钥存放的文件路径

ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa

//将公钥拷贝到目标服务器上 username是用户,remote-hostname是服务器

scp ~/.ssh/id_rsa.pub username@remote-hostname:~/temp 


第二步:目标服务器

//新建目录 

mkdir -p ~/.ssh  

//改变权限

chmod 700 .ssh  

//相当于重命名公钥位authorized_keys

cat temp >> ~/.ssh/authorized_keys

//改变权限  

chmod 600 ~/.ssh/authorized_keys 

//删除临时文件

rm -rf temp 

注意权限一定要设置


第三步:测试

ssh username@romote-hostname

分类:ubuntu, 软件安装
Linux Distribution Chooser 你适合哪个linux发行版
制作你的Ubuntu ID Card

13 则回应给 “小记:Linux下设置ssh免认证登录服务器”

  1. [zt]小记:Linux下设置ssh免认证登录服务器 UNITED STATES WordPress 说道:
    2011年07月16日 3:51 下午

    [...] ssh username@romote-hostname 转自:http://www.freetstar.com/index.php/linux-ssh-remote-host-without-passwd/comment-page-1#comment-4105 [...]

  2. RichL0ve Google Chrome Linux 说道:
    2011年07月16日 3:46 下午

    好文,学习了 :-D ,实现免密码登录,方便了好多

    [回复]

    freetstar CHINA Google Chrome Linux 回复:
    七月 16th, 2011 at 4:07 下午

    @RichL0ve, 恩恩,

    [回复]

  3. 9hills CHINA Google Chrome Windows 说道:
    2010年10月13日 4:28 下午

    Mark,留下备用。。

    [回复]

    freetstar CHINA Google Chrome Windows 回复:
    十月 13th, 2010 at 4:32 下午

    好的 :roll:

    [回复]

  4. 远走高飞 Mozilla Firefox Windows 说道:
    2010年08月18日 10:53 上午

    学习了

    [回复]

    freetstar CHINA Google Chrome Linux 回复:
    八月 18th, 2010 at 1:22 下午

    :)

    [回复]

  5. Mucid CHINA Mozilla Firefox Windows 说道:
    2010年08月17日 9:01 下午

    我也很神奇,这两天vps被我整挂了两次。。 :-?

    [回复]

    freetstar CHINA Google Chrome Linux 回复:
    八月 18th, 2010 at 1:22 下午

    :mrgreen: 折腾下其实也挺好的

    [回复]

  6. ikeeptrying CHINA Internet Explorer Windows 说道:
    2010年08月17日 10:13 上午

    07级的行家啊~~

    [回复]

    freetstar CHINA Google Chrome Linux 回复:
    八月 17th, 2010 at 12:50 下午

    没有没有。。

    [回复]

  7. 奶牛 CHINA Mozilla Firefox Windows 说道:
    2010年08月16日 9:34 下午

    吼吼,沙发咯,学习一下~~~~

    [回复]

    freetstar CHINA Google Chrome Linux 回复:
    八月 17th, 2010 at 12:51 下午

    :mrgreen: 8)

    [回复]

发表评论 取消回复

电子邮件地址不会被公开。 必填项已用 * 标注

*

*


疑问 开心 悲伤 邪恶 惊叹 微笑 脸红 笑 惊讶 惊奇 迷惑 酷 憨笑 生气 阴险 转眼球 眨眼 主意 箭头 中立 哭 大笑

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image

点击取消回复
第 1 页,共 1 页1
  • 欢迎订阅

  • Github

  • 近期评论

    • freetstar CHINA Mozilla Firefox Linux 发表在《留言板》
    • _Fly CHINA Google Chrome Linux 发表在《使用e4rat加速你的linux启动速度(ext4文件系统专用)》
    • walfred Mozilla Firefox Windows 发表在《留言板》
    • freetstar CHINA Mozilla Firefox Windows 发表在《用landslide创建html5 slide》
  • Spread Firefox Affiliate Button
  • 我的豆瓣

  • 链接表

    • 51开源社区
    • Adam's
    • delectate's blog
    • Don's
    • fl
    • ghostunix
    • Jasey Wang
    • Jerry's Blog
    • Moolight@Ericyue
    • OSMSG
    • panda
    • Pity is the Bomp
    • PT ubuntu
    • Tao Zhu
    • ubuntuhome
    • WOW!ubuntu
    • zhangzhfang
    • 丕字的blog
    • 傻东の学习笔记
    • 奶牛的blog
    • 孤风颠影
    • 弯柚博客
    • 熊猫党军委主席
    • 靖 轩
    • 马力哥
    • 黑孩儿
  • 我的支付宝

  • 功能

    • 登录
    • 文章 RSS
    • 评论 RSS
    • WordPress.org
© FreeTstar. WordPress 强力驱动 | Nest Theme by YChong