标签:port 验证 不同 logs cti art etc 服务端 roo
本地操作直接shell登陆处理,那远程操作就需要ssh,ssh提供加密验证和传输,提高通信的安全程度。
生成客户端密钥:
$ ssh-keygen -t rsa
$ > passphrase: <passwd> # used when decrypt privatekey on connecting to server
$ ssh-copy-id -i ~/.ssh/id_dsa.pub myname@www.server.com
在~/.ssh下生成私钥id_rsa和公钥id_rsa.pub,
同时将公钥传给sshd服务器www.server.com, 存放于服务器的~/.ssh/authorized_keys文件中,每行一个授权客户;
配置连接不同服务器使用不同的账号和密钥:
cat ~/.ssh/config
$ cat ~/.ssh/config host server1 user name1 hostname ip1 port 22 identityfile ~/.ssh/id_rsa1 host server2 user name2 hostname ip2 port 23 identityfile ~/.ssh/id_rsa2 $ ssh server1 $ ssh server2
在服务器添加访问账户:name1:passwd1
在/etc/ssh/sshd_config配置登录选项和密钥位置,允许ssh登录的用户
AllowUsers name1
PermitRootLogin no
StrictModes no RSAAuthentication yes PubkeyAuthentication yes PasswordAuthentication no
# after modify sshd_config, restart sshd $ /etc/init.d/ssh restart
$ ssh name1@<server1>
[name1@server1]$
$ ssh name1@<server1> "echo connected >> log/ssh.log" $ ssh -i ~/.ssh/id_rsa2 name2@<server2> $ ssh server2
# copy local file to server $ scp dir1/filea name1@<server_ip>:server_dir/ # copy server dir to local $ scp -r -P port_num name1@server_ip:server_dir local_tmp/
标签:port 验证 不同 logs cti art etc 服务端 roo
原文地址:http://www.cnblogs.com/futurespace/p/7442093.html