don't stop believing

[Ubuntu] ssh 접속 본문

Linux/Basic

[Ubuntu] ssh 접속

Tongchun 2017. 8. 30. 16:10

Ubuntu를 설치하고 나면 원격으로 접속할 수 있게 ssh 연결 설정을 해야 한다.

ssh server를 설치하면 되는데 우선 Ubuntu에 설치되어 있는 패키지 목록을 확인해보자.


설치된 패키지 목록 확인은 dpkg -l로 확인할 수 있다.

$ dpkg -l

너무 많은 목록이 나오기 때문에 ssh 관련 목록만 확인해 보자.

$ dpkg -l | grep ssh
ii  libssh-4:amd64          0.6.3-4.3             amd64    tiny C SSH library (OpenSSL flavor)
ii  openssh-client          1:7.2p2-4ubuntu2.2    amd64    secure shell (SSH) client, for secure access to remote machines
ii  openssh-server          1:7.2p2-4ubuntu2.2    amd64    secure shell (SSH) server, for secure access from remote machines
ii  openssh-sftp-server     1:7.2p2-4ubuntu2.2    amd64    secure shell (SSH) sftp server module, for SFTP access from remote machines
ii  ssh-import-id           5.5-0ubuntu1          all      securely retrieve an SSH public key and install it locally

설치되어 있지 않다면 openssh-server를 설치한다.

$ sudo apt-get install openssh-server

설치가 완료되었다면 ssh 포트인 22번이 열려있는지 확인합니다.

$ netstat -ntlp

이제 Ubuntu에서 ssh 연결에 대한 준비는 끝났다.

Windows 에서 puty 또는 xShell 5 등의 터미널 프로그램으로 접속을 해본다.

접속 명령은 ssh <계정명>@<서버 IP>이다. 접속이 정상적으로 맺여지면 계정에 대한 비밀번호를 묻는다.

$ ssh ngle@192.160.0.10

AWS에 있는 서버와 ssh로 연결할때는 보통 pem이라는 key 파일을 사용합니다. 이럴때는 -i 옵션으로 key 파일을 추가하면 됩니다.

전달받은 pem 파일이 있는 곳으로 이동 후 ssh -i <key 파일> <유저 계정>@<서버 IP>의 형태로 사용됩니다.

key 파일명이 access.pem 파일이라면 아래와 같이 사용됩니다.

$ sudo ssh -i access.pem user@123.12.10.43

access.pem 파일의 Permission 이슈가 있으며 sudo로 실행하면 됩니다.


이상 ssh 연결 방법이었습니다.



Comments