scp는 ssh를 통해 cp를 수행하는데..
cp 명령답게 scp target destination  식으로 옵션을 주어야 한다 -_-

그리고 sftp에 비해서 편한점은 -P port 옵션이 기본 제공된다는 점?

usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
           [-l limit] [-o ssh_option] [-P port] [-S program]
           [[user@]host1:]file1 ... [[user@]host2:]file2
 
usage: sftp [-1Cv] [-B buffer_size] [-b batchfile] [-F ssh_config]
            [-o ssh_option] [-P sftp_server_path] [-R num_requests]
            [-S program] [-s subsystem | sftp_server] host
       sftp [user@]host[:file ...]
       sftp [user@]host[:dir[/]]
       sftp -b batchfile [user@]host

[링크 : http://linux.die.net/man/1/scp]
[링크 : http://canworld.tistory.com/43]

아무튼, 경로상에 스페이스(공백문자)가 들어있다면 " \ " 로 넣어주면 된다.
예를들어 "/home/user 1" 이라는 경로가 있다면
scp "/home/user
\ 1" 이라고 입력을 하면된다. escape 치환은 " " 안에서만 되는걸려나?

[링크 : http://www.thingy-ma-jig.co.uk/blog/14-05-2007/how-to-scp-a-path-with-spaces]
Posted by 구차니
회사 외부에서 회사 Redhat 서버로 접속하고
Redhat 서버에서 Ubuntu 서버로 접속하면 X11이 두단계를 거쳐 띄울수가 있다.

그런데.. 회사 내부에서 Ubuntu 에서 접속하고 Redhat으로 접속하면.. 왜 안될까?

아마도
 /etc/ssh/ssh_config
파일의 설정이 달라서 그런듯하다.

레드햇 쪽은 아래와 같은 설정이 되어있다.
Host *
        ForwardX11 yes

그에반해 우분투 10.04 LTS는
Host *
    SendEnv LANG LC_*
    HashKnownHosts yes
    GSSAPIAuthentication yes
    GSSAPIDelegateCredentials no

이렇게 입력이 되어있다.
아마도 X11 Forwarding (터널링이 아닌)이 설정되어 있어서 다중으로 가능한 것으로 보인다.


2015.09.24

x11forwarding default no

http://linux.die.net/man/5/sshd_config

Posted by 구차니
서버를 교체하거나, 서버의 아이피 변경으로 인해 기존의 서버의 아이피와 겹칠경우
${HOME}/.ssh/known_hosts
파일에 이전의 정보가 남아있는 바람에 생기는 에러이다.
"에러" 라고 한이유는, 경고라고 해놓고 접속이 안되기 때문이다.

해결 방법은, 위의 파일을 삭제하거나(그러면 다음 접속시 키를 다 받아야 하는 귀차니즘이)
해당 서버의 아이피가 들어있는 줄을 지우면 된다.

$ ssh USERID@SERVER_IP
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
5b:c1:63:e6:6c:53:30:ea:fd:fd:f3:72:22:a0:a1:aa.
Please contact your system administrator.
Add correct host key in /home/USERID/.ssh/known_hosts to get rid of this message.
Offending key in /home/USERID/.ssh/known_hosts:2
RSA host key for SERVER_IP has changed and you have requested strict checking.
Host key verification failed.

Posted by 구차니
sftp는 ssh를 이용한 ftp이다.
별다르게 설정하지 않았다면, 기본값으로 ssh를 통해 sftp로 전송이 가능하다.

SYNOPSIS
     sftp [-1Cv] [-B buffer_size] [-b batchfile] [-F ssh_config]
          [-o ssh_option] [-P sftp_server_path] [-R num_requests] [-S program]
          [-s subsystem | sftp_server] host
     sftp [[user@]host[:file [file]]]
     sftp [[user@]host[:dir[/]]]
     sftp -b batchfile [user@]host

사용방법은 위와 같은데 간단하게 예를 들자면,

# sftp root@192.168.10.10:/home.tar home.tar
Connecting to 192.168.10.10...
root@192.168.10.10's password:
Fetching /home.tar to home.tar
/home.tar                                       8% 1811MB   6.3MB/s   49:58 ETA

처럼 사용하면 된다. 머랄까.. 저 형식은 cvs나 svn 포맷같기도 하고..
Posted by 구차니
ssh를 사용하면 sftp는 기본으로 사용할 수 있게 된다.
문득, sftp를 막을 수 있는 방법을 없을까? 라는 생각이 들었는데..
아래의 링크에서 사용하지 못하도록 하는 방법을 찾게 되었다.

$ vi /etc/ssh/sshd_config
 72 # Allow client to pass locale environment variables
 73 AcceptEnv LANG LC_*
 74
 75 Subsystem sftp /usr/lib/openssh/sftp-server
 76
 77 UsePAM yes



 75 #Subsystem sftp /usr/lib/openssh/sftp-server
로 해주면 된다고 한다.

※ ubuntu 9.04의 sshd_config파일 행번호임.

원본 내용은 RHEL(RedHat Enterprise Linux) 에 적용되지만
Ubuntu 9.04 역시 동일하게 존재한다.

[링크 : http://blog.seabow.pe.kr/513]


배포판마다 다르지만 sftp-server 라는 실행파일이 존재합니다
/usr/lib/sftp-server에 없다면 find로 검색해서 찾아보시기 바랍니다.
#find / -name sftp-server  (root권한으로 하는게 좋습니다.)
하면 경로가 나옵니다.
그 경로가 만약
/usr/lib/misc/sftp-server면 이 경로를

#echo "/usr/lib/misc/sftp-server" >> /etc/shells 로 허가 쉘 목록에 추가해줍니다.
그런후에
#usermod -s /usr/lib/misc/sftp-server  사용자id
해주면 그 사용자는 sftp만 허용됩니다.

[링크 : http://phpschool.com/gnuboard4/bbs/board.php?bo_table=qna_install&wr_id=82505]

Posted by 구차니
SSH로 서버에 접속 후,
서버에서 로컬의 다른 서버로  SSH 접속을 하는데 아래와 같은 경우를 만났다.

[userid@hostname ~]$ ssh localserver_ip
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00.
Please contact your system administrator.
Add correct host key in /home/userid/.ssh/known_hosts to get rid of this message.
Offending key in /home/userid/.ssh/known_hosts:1
RSA host key for 192.168.10.10 has changed and you have requested strict checking.
Host key verification failed.

해결방법은, 그냥 저 파일을 지우면 된다.
(아마.. 지금까지 접속했던 서버들에 대한 RSA 키도 전부 삭제 되므로, 다음번 접속시 전부 키를 받을 거냐고 물어볼 듯 하다)
Posted by 구차니
우분투에 ssh를 설치후 접속하면 아래와 같이 무진장 긴 메시지가 나온다

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/

/etc/motd.tail 파일을 수정하면 우분투 ssh 접속시 나오는 메시지를 바꿀수 있다고 한다.
하지만 데비안 계열은 이 내용을 수정하는 것은 불법이라고 하는데.. 조금 짜증나도 냅둬야 하나?

[링크: http://www.coveredjin.com/tag/ssh%20%EB%A9%94%EC%84%B8%EC%A7%80]

2010.02.04 추가
/etc/issue 파일에 일반적으로 로그인시 출력하는 메시지가 들어있다.
Posted by 구차니
sudo apt-get 방식으로 편하게 설치가 가능하다.

패키지 이름은 ssh 이며
sudo apt-get install ssh
라고 입력하면 바로 설치 된다.

ubuntu 8.10 에서 실행시 별다른 설정없이 기본 포트인 22번으로 바로 실행이 되며,
X11 Forwarding 역시 문제 없이 별다른 설정없이 가능했다.

[출처 : http://sanghoon.wordpress.com/2007/12/05/]
Posted by 구차니