2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Linux】ftpへのファイル転送

Last updated at Posted at 2018-03-20

## ftpサーバーへ接続

shell

# 致命的エラー: gnutls_handshake: An unexpected TLS packet was received.
#  解決案:

[root@server ~]# lftp -u user,pass -p 21 ftp://sample.jp
lftp user@sample.jp:~> set ftp:ssl-auth TLS
lftp user@sample.jp:~> set ftp:ssl-force true
lftp user@sample.jp:~> set ftp:ssl-allow yes
lftp user@sample.jp:~> set ftp:ssl-protect-list yes
lftp user@sample.jp:~> set ftp:ssl-protect-data yes
lftp user@sample.jp:~> set ftp:ssl-protect-fxp yes
lftp user@sample.jp:~> set ssl:verify-certificate no
lftp user@sample.jp:~> set cmd:fail-exit yes
lftp user@sample.jp:~>
lftp user@sample.jp:~> ls
drwxrws---    6 3003     3003         4096 Jul 26  2017 a
lftp user@sample.jp:/>bye
[root@server ~]# 

## ftpサーバーへファイル転送

shell

# shell.sh ファイル転送shell

retcode=0
lftp -c "DEBUG -o /var/www/html/log/`date '+%Y%m%d%H%M%S'`'.log'; \
      set ftp:ssl-force true; \
      set cmd:fail-exit yes; \
      set ftp:ssl-auth TLS; \
      set ssl:verify-certificate no; \
      set ftp:ssl-allow yes; \
      set ftp:ssl-protect-list yes; \
      set ftp:ssl-protect-data yes; \
      set ftp:ssl-protect-fxp yes; \
      open -p $port $host; \
      user $username $password; \
      put $srcfilepath -o $dstfilepath; " 2>&1
if [[ ${?} -ne 0 ]]; then
    echo `date` " [ERROR] 転送失敗" | tee -a '/var/www/html/log/'`date '+%Y%m%d'`'.log'
    retcode=1
else
    echo `date` " [INFO] 転送完了" | tee -a '/var/www/html/log/'`date '+%Y%m%d'`'.log'
fi
exit ${retcode}

参考
致命的エラー: gnutls_handshake

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?