o ssh 로 상대방 서버에 자동으로 접속하기
!!! root 로 사용하지 말고 일반사용자를 이요해서 복사 !!!
1. 공개키를 생성
2. 상대방서버에 복사 ( authorized_keys )
3. 상대방서버에 접속
1. 공개키를 생성
[sshtest1@mail sshtest1]$ ssh-keygen -t dsa -N ""
Generating public/private dsa key pair.
Enter file in which to save the key (/home/sshtest1/.ssh/id_dsa):
Your identification has been saved in /home/sshtest1/.ssh/id_dsa.
Your public key has been saved in /home/sshtest1/.ssh/id_dsa.pub.
The key fingerprint is:
e2:60:e8:03:11:7b:c5:82:d4:53:1e:08:24:9b:0f:74 sshtest1 at mail.xno.cc
o 만들어진 공개키를 확인
[sshtest1@mail sshtest1]$ cd .ssh/
[sshtest1@mail .ssh]$ ls
id_dsa id_dsa.pub known_hosts
2. 상대방서버에 복사
[sshtest1@mail .ssh]$ scp id_dsa.pub 192.168.53.4:.ssh/authorized_keys
<a href="mailto:sshtest1@192.168.53.4">sshtest1@192.168.53.4</a>'s password:
id_dsa.pub 100% 610 0.6KB/s 00:00
3. 상대방 서버에 접속
[sshtest1@mail .ssh]$ ssh 192.168.53.4
Last login: Thu Nov 4 12:14:43 2004 from 211.254.138.69
4. alias 를 이용해서 좀더 편하게 접속
[sshtest2@mail sshtest2]$ alias S4="ssh 192.168.53.4"
[sshtest2@mail sshtest2]$ S4
Last login: Thu Nov 4 12:33:38 2004 from 211.254.138.69
[sshtest2@freedi sshtest2]$
########################
root로 ssh 로그인금지
########################
- ssh 사용시 default로 root로그인이 허용된다. 이를 막기위해선
#vi /etc/ssh/sshd_config
--------------------------------------------------------
#PermitRootLogin yes --> PermitRootLogin no 로 수정하셔
--------------------------------------------------------