1

ssh相关

 2 years ago
source link: http://wwj718.github.io/post/%E5%B7%A5%E5%85%B7/ssh/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

ssh相关

2014-07-10

##安装(ubuntu)

sudo apt-get install openssh-server

##配置 ###允许密码配置 vim /etc/ssh/sshd_config使:

PasswordAuthentication yes

###安全相关 修改登录端口

vim /etc/ssh/sshd_config使:

Port [port]

端口号选择大一些,被随机扫描的可能性更小

###使用密钥登录并禁止口令登录实践 这是最相对安全的登录管理方式

:::text
#以下用户都是root(sudo)

#生成SSH密钥对,一路回车就行
ssh-keygen -t rsa

#复制公钥到无密码登录的服务器上,22端口改变可以使用下面的命令
#ssh-copy-id -i ~/.ssh/id_rsa.pub -p 10022 user@server
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
#登录时需要使用相应账号登录

#也可以登录被控机器后 cd .ssh,wget https://github.com/wwj718.keys 之后chmod 600 authorized_keys
#authorized_keys 文件必须是600权限或者644
#.ssh目录必须是700权限
#/home/ubuntu 目录必须是755权限

#修改SSH配置文件
#编辑sshd_config文件
vi /etc/ssh/sshd_config

#禁用密码验证
PasswordAuthentication no
#启用密钥验证
RSAAuthentication yes
PubkeyAuthentication yes
#指定公钥数据库文件
AuthorsizedKeysFile .ssh/authorized_keys

#重启SSH服务前建议多保留一个会话以防不测

#手动增加管理用户
echo 'ssh-rsa XXXX' >>/root/.ssh/authorized_keys

# 复查
cat /root/.ssh/authorized_keys
:::text
#RHEL/CentOS系统
service sshd restart
#ubuntu系统
service ssh restart
#debian系统
/etc/init.d/ssh restart

#补遗 ###X11 Forwarding 通过使用ssh -X user@host,可以做到开启远端GUI应用,就像在本地开启一样,max下需要安装Quartz


2016-05-04修改

SSH 简化配置

  • 强烈建议使用 ssh-copy-id来移动你的公共密钥
  • 使用~/.ssh/config, 你可以在~/.ssh/config里面指定相当数量的配置选项,强烈建议看网上的文档或者 ssh_config 手册页
:::text
# contents of $HOME/.ssh/config
Host dev
    HostName dev.example.com
    Port 22000
    User fooey

ssh startx

使用ssh进入图形界面

How do I access my remote Ubuntu server via X-windows from my Mac


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK