如何在远程服务器上通过 ssh 执行多个命令

时间:2021-05-25 16:16:49

标签: shell ssh

我想通过shell脚本从AWS bucket中获取日志,下面是我的示例脚本,它在获取日志文件的路径上一一走。

echo "Enter user_name"
read name
echo "Enter the bucket for which you want to see the logs"
echo "applicationLogs / nginxLogs"
echo
read bucket_logs
echo "Enter the Date (yyyy-mm-dd:)"
read date
echo "Enter the bucket server ip"
read bucket_ip
echo $bucket_ip > iplist

newip=$(sed 's/\./-/g' iplist)
aws_server_ip="1*.4*.2*.2**"
IP="ip"
bucket_region="ap-south-1.compute.internal"
aws_bucket="aws s3 ls s3://wallet-prod-backup-bucket/"

ssh $name@$aws_server_ip ${aws_bucket}{${bucket_logs}/${bucket_ip}/${IP}-${newip}.${bucket_region}/${date}/alog/wallet-service/walletlogs/wallet-service/

我需要运行多个命令(即首先我通过 ssh-ing 进入服务器,然后我需要通过不同的路径复制日志文件夹)。 当我从我的机器本地运行这个脚本时,它会转到所需的路径,列出日志文件,但立即从服务器退出。 有什么方法可以让我在不退出远程服务器的情况下通过 ssh 运行命令?

0 个答案:

没有答案