리눅스 scp 자동화

(SCP 자동화에서 넘어옴)
scp 자동화

1 방법 1: sshpass + scp[ | ]

명령어
sshpass -p패스워드 scp -o StrictHostKeyChecking=no 로컬파일 아이디@호스트주소:/폴더/파일명
실행예시
[root@zetawiki ~]# sshpass -pP@ssw0rd scp -o StrictHostKeyChecking=no hello.txt root@135.79.246.99:/root/hello.txt
→ 135.79.246.80(jmnote)에서 135.79.246.99(jmtest01)로 hello.txt 복사

2 방법 2: expect + scp[ | ]

명령어
expect <<EOF
spawn scp -oStrictHostKeyChecking=no hello.txt 아이디@호스트주소:/폴더/위치/
expect "password:"
        send "패스워드\r"
expect eof
EOF
실행예시
[root@zetawiki ~]# expect <<EOF
> spawn scp -oStrictHostKeyChecking=no hello.txt root@135.79.246.99:/root/
> expect "password:"
>         send "P@ssw0rd\r"
> expect eof
> EOF
spawn scp -oStrictHostKeyChecking=no hello.txt root@135.79.246.99:/root/
root@135.79.246.99's password: 
hello.txt                                                100%    6     0.0KB/s   00:00

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}